* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-muted); color: var(--text-primary); font: 16px/1.6 var(--font-primary); }
button, textarea { font: inherit; }
button:focus-visible, textarea:focus-visible { outline: 3px solid rgb(13 110 253 / 35%); outline-offset: 2px; }
.site-header { display: flex; align-items: center; gap: var(--space-3); max-width: 860px; margin: 0 auto; padding: 20px 16px 8px; flex-wrap: wrap; }
.site-nav { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.nav-toggle { display: none; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text-primary); font-size: 20px; line-height: 1; cursor: pointer; }
.header-action { color: var(--brand); font-weight: 650; text-decoration: none; }
.brand, .meta-link { color: var(--brand); font-weight: 700; text-decoration: none; }
/* 管理员功能集中在页头下拉菜单，避免多个管理入口挤占导航空间。 */
.admin-menu { position: relative; flex: 0 0 auto; }
.admin-menu > summary { cursor: pointer; list-style: none; }
.admin-menu > summary::-webkit-details-marker { display: none; }
.admin-menu > summary::after { content: "▾"; margin-left: 5px; font-size: .75rem; }
.admin-menu[open] > summary::after { content: "▴"; }
.admin-menu-dropdown { display: grid; position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; min-width: 180px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / 15%); }
.admin-menu-dropdown a { padding: 8px 10px; border-radius: 5px; color: var(--text-primary); text-decoration: none; white-space: nowrap; }
.admin-menu-dropdown a:hover, .admin-menu-dropdown a:focus-visible { background: var(--surface-muted); color: var(--brand); }
.header-caption, .footer-hint, .source-note, .meta-muted, time { color: var(--text-muted); font-size: .9rem; }
.page-shell { max-width: 860px; margin: 0 auto; padding: 12px 16px 56px; }
.page-intro { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); margin: 18px 0 20px; }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-weight: 700; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.45rem, 4vw, 2rem); }
.intro-copy { margin-bottom: 0; color: var(--text-secondary); }
.admin-clean-list { display: grid; gap: 18px; }
.admin-clean-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.admin-clean-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.admin-clean-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px; }
.admin-clean-panel { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-muted); }
.admin-clean-panel h2 { margin: 0 0 8px; font-size: .95rem; }
.admin-clean-panel img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: var(--surface); }
.admin-clean-upload { display: flex; align-items: end; gap: 12px; padding: 0 16px 16px; }
.admin-clean-focus { align-self: end; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-muted); color: var(--text-primary); cursor: pointer; }
.admin-clean-focus:hover, .admin-clean-focus:focus-visible { border-color: var(--brand); color: var(--brand); }
.admin-clean-upload label { display: grid; flex: 1; gap: 6px; color: var(--text-secondary); }
.admin-clean-dropzone { padding: 12px; border: 2px dashed var(--border); border-radius: var(--radius-control); background: var(--surface-muted); cursor: pointer; }
.admin-clean-dropzone:focus-visible { outline: 3px solid rgb(13 110 253 / 35%); outline-offset: 2px; }
.admin-clean-dropzone:hover, .admin-clean-dropzone.is-dragging { border-color: var(--brand); background: var(--brand-soft); }
.admin-clean-dropzone input { width: 100%; }
.admin-clean-dropzone small { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-clean-preview-trigger { cursor: zoom-in; }
.admin-clean-modal[hidden] { display: none; }
.admin-clean-modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; }
.admin-clean-modal-backdrop { position: absolute; inset: 0; background: rgb(15 23 42 / 72%); }
.admin-clean-modal-content { position: relative; z-index: 1; width: min(1400px, 96vw); max-height: 94vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
.admin-clean-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.admin-clean-modal-header h2 { margin: 0; font-size: 1.1rem; }
.admin-clean-modal-close { border: 0; background: transparent; color: var(--text-primary); font-size: 2rem; line-height: 1; cursor: pointer; }
.admin-clean-modal-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 18px; }
.admin-clean-modal-comparison h3 { margin: 0 0 8px; font-size: 1rem; }
.admin-clean-modal-comparison img { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: var(--surface-muted); }
.admin-clean-modal-open { overflow: hidden; }
@media (max-width: 680px) { .admin-clean-comparison { grid-template-columns: 1fr; } .admin-clean-upload { align-items: stretch; flex-direction: column; } .admin-clean-focus { align-self: stretch; } }

/* 学生情况统计面板：身份信息、三科状态和高频标签集中展示。 */
.student-dashboard { display: grid; gap: 16px; margin: 18px 0 24px; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(135deg, var(--surface) 0%, var(--surface-muted) 100%); box-shadow: 0 8px 24px rgb(26 49 82 / 8%); }
.student-dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 4px; }
.student-identity { display: flex; align-items: center; gap: 13px; min-width: 0; }
.student-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); font-size: 1.2rem; font-weight: 750; }
.student-identity h1 { margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(1.2rem, 3vw, 1.55rem); }
.student-total { display: grid; flex: 0 0 auto; justify-items: end; color: var(--text-muted); }
.student-total strong { color: var(--brand); font-size: 1.65rem; line-height: 1.1; }
.student-total span { font-size: .82rem; }
.subject-stat-list { display: grid; gap: 8px; }
.subject-stat { display: grid; grid-template-columns: 76px minmax(250px, 1fr) minmax(0, 1.65fr); align-items: center; gap: 16px; min-height: 62px; padding: 10px 14px; border: 1px solid transparent; border-radius: 11px; background: var(--surface); }
/* 每个科目条目的彩色边框，按序号循环取色 */
.subject-stat-1 { border-color: rgb(23 105 170 / 18%); }   /* 品蓝 */
.subject-stat-2 { border-color: rgb(138 99 210 / 20%); }   /* 紫罗兰 */
.subject-stat-3 { border-color: rgb(215 131 63 / 22%); }   /* 琥珀橙 */
.subject-stat-4 { border-color: rgb(32 155 143 / 20%); }   /* 青碧 */
.subject-stat-5 { border-color: rgb(196 72 100 / 20%); }   /* 玫瑰红 */
.subject-stat-6 { border-color: rgb(65 120 170 / 20%); }   /* 钢蓝 */
.subject-stat-7 { border-color: rgb(172 130 12 / 22%); }   /* 金黄 */
.subject-stat-8 { border-color: rgb(92 148 80 / 20%); }    /* 草绿 */
.subject-name { display: flex; align-items: center; gap: 8px; }
.subject-stat strong { font-size: 1rem; }
/* 科目指示点：颜色与对应边框保持一致 */
.subject-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.subject-stat-2 .subject-dot { background: #8a63d2; box-shadow: 0 0 0 4px rgb(138 99 210 / 14%); }
.subject-stat-3 .subject-dot { background: #d7833f; box-shadow: 0 0 0 4px rgb(215 131 63 / 14%); }
.subject-stat-4 .subject-dot { background: #209b8f; box-shadow: 0 0 0 4px rgb(32 155 143 / 14%); }
.subject-stat-5 .subject-dot { background: #c44864; box-shadow: 0 0 0 4px rgb(196 72 100 / 14%); }
.subject-stat-6 .subject-dot { background: #4178aa; box-shadow: 0 0 0 4px rgb(65 120 170 / 14%); }
.subject-stat-7 .subject-dot { background: #ac820c; box-shadow: 0 0 0 4px rgb(172 130 12 / 14%); }
.subject-stat-8 .subject-dot { background: #5c9450; box-shadow: 0 0 0 4px rgb(92 148 80 / 14%); }
.subject-counts { display: flex; justify-content: space-between; gap: 12px; }
.subject-stat-item { color: var(--text-secondary); font-size: .85rem; white-space: nowrap; }
.subject-stat-item b { margin-left: 4px; color: var(--text-primary); font-size: 1rem; }
.subject-stat-unmastered b { color: var(--danger); }
.subject-stat-mastered b { color: var(--success); }
/* 科目统计过滤链接：去掉默认链接样式，加可点击光标和 hover 高亮 */
.subject-filter-link { text-decoration: none; color: inherit; cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; transition: background .15s; }
.subject-filter-link:hover { background: var(--brand-soft); }
.subject-filter-link.subject-filter-active { background: var(--brand-soft); outline: 1.5px solid var(--brand); outline-offset: 0; }
.subject-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.subject-tag { max-width: 100%; overflow: hidden; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-muted); color: var(--text-secondary); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.subject-tag b { margin-left: 2px; color: var(--brand); font-weight: 700; }
.subject-tags-empty { color: var(--text-muted); font-size: .8rem; }
@media (max-width: 680px) {
    .subject-stat { grid-template-columns: 64px minmax(0, 1fr); gap: 8px 12px; }
    .subject-counts { gap: 7px; }
    .subject-tags { grid-column: 1 / -1; padding-top: 3px; border-top: 1px solid var(--border); }
}
.top-tags-panel { padding-top: 2px; }
.top-tags-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.top-tags-heading span { color: var(--text-muted); font-size: .82rem; }
.top-tags-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.top-tags-list li { display: flex; align-items: center; gap: 9px; padding: 5px 0; color: var(--text-secondary); }
.top-tag-rank { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--brand-soft); color: var(--brand); font-size: .78rem; font-weight: 750; }
.top-tags-list li b { margin-left: auto; color: var(--text-primary); font-size: .85rem; }
.progress-chip, .status-badge, .panel-label { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 10px; font-size: .8rem; white-space: nowrap; }
.progress-chip { background: var(--brand-soft); color: var(--brand); }
/* 搜索栏与统计面板、题目卡片保持相同的圆角和浅色层次。 */
.mistake-search { margin: 0 0 16px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); }
.mistake-search form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px 12px; }
.mistake-search-field { display: grid; gap: 5px; }
.mistake-search label { color: var(--text-secondary); font-size: .8rem; font-weight: 650; }
.mistake-search select, .mistake-search input { min-height: 36px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-primary); font: inherit; }
.mistake-search select { min-width: 112px; }
.mistake-search input { width: 130px; }
.mistake-search button { min-height: 36px; padding: 7px 16px; border: 0; border-radius: 9px; background: var(--brand); color: white; font: inherit; font-weight: 700; cursor: pointer; }
.mistake-search button:hover { filter: brightness(.95); }
.mistake-search a { align-self: center; color: var(--brand); font-size: .85rem; text-decoration: none; }
@media (max-width: 680px) {
    /* 移动端将两个筛选字段并排放置，搜索按钮独占第二行，减少表单高度。 */
    .mistake-search form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
    .mistake-search-field { min-width: 0; }
    .mistake-search label, .mistake-search select, .mistake-search input { width: 100%; }
    .mistake-search button { grid-column: 1 / -1; width: 100%; }
}
.message-list { display: grid; gap: 16px; }
.mistake-message { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.message-header, .message-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; }
.message-header { border-bottom: 1px solid var(--border); }
.message-meta, .message-status, .section-title-row, .footer-actions, .form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
/* 题目编号、学段和科目必须保持完整一行；空间不足时由知识点标签区收缩。 */
.message-header > .message-meta { flex: 0 0 auto; flex-wrap: nowrap; white-space: nowrap; }
.message-header-right { display: flex; align-items: center; flex: 0 0 auto; flex-wrap: nowrap; gap: 10px; white-space: nowrap; }
.message-header-right form { margin: 0; }
.mastered-button { padding: 4px 11px; border: 1px solid transparent; border-radius: 999px; font-size: .8rem; font-weight: 700; cursor: pointer; }
.mastered-button-danger { background: var(--danger-soft); color: var(--danger); }
.mastered-button-success { background: var(--success-soft, #e9f7ef); color: var(--success); }
.mastered-button:hover { filter: brightness(.96); }
.mastered-button:focus-visible { outline: 3px solid rgb(13 110 253 / 35%); outline-offset: 2px; }
.message-created-at { white-space: nowrap; }
.knowledge-tags { display: grid; gap: 10px; margin: 0 0 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.message-header > .knowledge-tags { flex: 1 1 0; min-width: 0; margin: 0; padding: 0 8px; border: 0; background: transparent; }
.message-header > .knowledge-tags .knowledge-tags-header { justify-content: center; }
.message-header > .knowledge-tags .knowledge-tag-list { justify-content: center; }
.message-header > .knowledge-tags .knowledge-tag-editor { text-align: center; }
.message-header > .knowledge-tags .knowledge-tag-editor[open] form { justify-content: center; }
.knowledge-tags-header { min-width: 0; }
.knowledge-tags-header > strong, .knowledge-tags-header > .meta-muted { flex: 0 0 auto; }
.knowledge-tag-list { min-width: 0; flex: 1 1 auto; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.knowledge-tag-list .status-badge { flex: 0 0 auto; }
.knowledge-tag-list > .meta-muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-tag-actions { display: inline-flex; flex: 0 0 auto; gap: 0; }
.knowledge-tag-actions form { margin: 0; }
.tag-icon-button { display: inline-grid; place-items: center; width: 32px; height: 30px; padding: 0; border-radius: 0; font-size: 18px; line-height: 1; }
.knowledge-tag-actions > :first-child .tag-icon-button { border-radius: 4px 0 0 4px; }
.knowledge-tag-actions > :last-child .tag-icon-button { border-left: 0; border-radius: 0 4px 4px 0; }
.knowledge-tag-actions .htmx-request .tag-icon-button,
.knowledge-tag-actions .tag-icon-button.is-loading { opacity: .6; cursor: wait; }
.loading-spinner { display: block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: loading-spin .7s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.knowledge-tag-dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-primary); box-shadow: 0 16px 48px rgb(0 0 0 / 22%); }
.knowledge-tag-dialog::backdrop { background: rgb(0 0 0 / 42%); }
.knowledge-tag-dialog form { display: grid; gap: 14px; padding: 20px; }
.knowledge-tag-dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.knowledge-tag-dialog h3 { margin: 0; flex: 1; }
.knowledge-tag-dialog-close { flex: 0 0 auto; padding: 4px 8px; border: 0; background: transparent; color: var(--text-secondary); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 4px; }
.knowledge-tag-dialog-close:hover { background: var(--surface-muted); color: var(--text-primary); }
.knowledge-meta-row { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.knowledge-scope { margin: 0; flex: 0 0 auto; white-space: nowrap; }
.knowledge-quick-nav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.knowledge-quick-nav .btn { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.knowledge-tags-header, .knowledge-tag-list, .knowledge-tag-editor form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.knowledge-tags-header { justify-content: space-between; flex-wrap: nowrap; }
.knowledge-tag-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.knowledge-tag-editor summary { cursor: pointer; color: var(--brand); font-weight: 650; }
.knowledge-tag-editor form { align-items: flex-start; margin-top: 10px; }
/* 大纲模式：外层可滚动，子层用左内边距表现层级 */
.knowledge-outline { max-height: min(640px, calc(100vh - 200px)); overflow: auto; margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 6px; list-style: none; }
.knowledge-option-children { margin: 0; padding-left: 18px; border-left: 1px solid var(--border); list-style: none; }
.knowledge-option-row { display: flex; align-items: flex-start; gap: 8px; padding: 3px 4px; border-radius: 4px; color: var(--text-secondary); cursor: pointer; }
.knowledge-option-row:hover { background: var(--surface-muted); }
.knowledge-option.is-selected > .knowledge-option-row { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.knowledge-option.is-highlighted > .knowledge-option-row { animation: highlight-flash 1.2s ease-out; }
@keyframes highlight-flash {
  0%, 100% { background: var(--brand-soft); }
  50% { background: var(--brand); color: white; }
}
.knowledge-option-row input { margin-top: 3px; flex: 0 0 auto; }
.mistake-message .question-number { color: var(--brand); font-size: 1rem; font-weight: 700; }
.status-badge { background: var(--surface-muted); color: var(--text-secondary); }
.status-needs-review, .status-failed { background: var(--danger-soft); color: var(--danger); }
.status-needs-proofreading, .status-manual-takeover { background: var(--warning-soft); color: var(--warning); }
.status-published { background: #e9f7ef; color: var(--success); }
.message-body { padding: 20px; }
.question-screenshot { margin: 0 0 20px; padding: 10px; border-radius: 10px; background: var(--surface-muted); }
.question-screenshot img { display: block; width: 100%; max-height: 360px; object-fit: contain; border-radius: 6px; cursor: zoom-in; }
.question-screenshot figcaption { margin-top: 8px; color: var(--text-muted); font-size: .85rem; }
.clean-image-link-wrapper { display: inline; }
.clean-image-link { margin-left: 12px; padding: 2px 8px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); font-weight: 600; cursor: pointer; transition: background var(--motion-fast), color var(--motion-fast); }
.clean-image-link:hover { background: var(--brand); color: white; }
.clean-image-link-processing { cursor: default; opacity: 0.7; }
.clean-image-link-processing:hover { background: var(--brand-soft); color: var(--brand); }
.image-preview-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; overflow: hidden; padding: 52px 24px 24px; border: 0; background: rgb(0 0 0 / 86%); }
.image-preview-dialog[open] { display: grid; place-items: center; }
.image-preview-dialog::backdrop { background: rgb(0 0 0 / 86%); }
.image-preview-dialog img { display: block; width: auto; height: auto; max-width: calc(100vw - 48px); max-height: calc(100vh - 76px); object-fit: contain; border-radius: 4px; cursor: zoom-out; }
.image-preview-close { position: absolute; top: 12px; right: 16px; width: 40px; height: 40px; padding: 0; border: 1px solid rgb(255 255 255 / 45%); border-radius: 50%; background: rgb(0 0 0 / 35%); color: white; font-size: 28px; line-height: 1; cursor: pointer; }
.image-preview-close:hover { background: rgb(255 255 255 / 18%); }
@media (max-width: 600px) { .image-preview-dialog { padding: 52px 12px 12px; } }
.image-empty { display: grid; place-items: center; min-height: 150px; color: var(--text-muted); }
.attempt-panel { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.attempt-upload-form { display: grid; gap: 10px; margin-top: 12px; }
.attempt-upload-form[hidden] { display: none; }
.attempt-panel .section-title-row { align-items: center; }
.attempt-panel .section-title-row h3 { margin: 0; }
.attempt-panel [data-toggle-attempt-upload] { margin-left: auto; }
.attempt-upload-zone { display: grid; gap: 6px; padding: 16px; border: 2px dashed var(--border); border-radius: var(--radius-control); background: var(--surface-muted); color: var(--text-secondary); text-align: center; cursor: pointer; transition: border-color var(--motion-fast), background var(--motion-fast); }
.attempt-upload-zone input[type="file"] { cursor: pointer; }
.attempt-upload-zone strong { display: block; color: var(--text-primary); }
.attempt-upload-zone span { display: block; color: var(--text-muted); font-size: .85rem; }
.attempt-upload-zone:hover, .attempt-upload-zone:focus-within { border-color: var(--brand); }
.attempt-upload-zone.is-dragging { border-color: var(--brand); background: var(--brand-soft); }
.attempt-upload-form .selected-image-list { margin: 0; padding-left: 1.2rem; color: var(--text-secondary); font-size: .9rem; }
.attempt-upload-form .selected-image-list:empty { display: none; }
.attempt-upload-form .inline-form-error { margin: 0; color: var(--danger); font-size: .9rem; }
.attempt-upload-form button[type="submit"] { justify-self: start; }
.attempt-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.attempt-item-wrapper { position: relative; }
.attempt-item { display: grid; gap: 4px; width: 120px; padding: 5px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-muted); color: var(--text-muted); cursor: pointer; text-align: left; }
.attempt-item.is-active { border-color: var(--brand); }
.attempt-item img { display: block; width: 100%; height: 88px; object-fit: contain; background: var(--surface); }
.attempt-item time { font-size: .72rem; }
.attempt-delete-btn { position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; padding: 0; border: none; border-radius: 4px; background: rgba(180, 35, 24, 0.9); color: white; cursor: pointer; opacity: 0; transition: opacity var(--motion-fast); z-index: 1; }
.attempt-delete-btn:hover { background: var(--danger); }
.attempt-item-wrapper:hover .attempt-delete-btn { opacity: 1; }
.attempt-zoom-btn { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; padding: 0; border: none; border-radius: 4px; background: rgba(13, 110, 253, 0.9); color: white; cursor: pointer; opacity: 0; transition: opacity var(--motion-fast); z-index: 1; }
.attempt-zoom-btn:hover { background: var(--brand); }
.attempt-item-wrapper:hover .attempt-zoom-btn { opacity: 1; }
.image-zoom-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.image-zoom-modal[hidden] { display: none; }
.image-zoom-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.8); cursor: pointer; }
.image-zoom-content { position: relative; max-width: 90vw; max-height: 90vh; z-index: 1; }
.image-zoom-img { max-width: 100%; max-height: 90vh; display: block; border-radius: 8px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); }
.image-zoom-close { position: absolute; top: -40px; right: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; padding: 0; border: none; border-radius: 50%; background: rgba(255, 255, 255, 0.9); color: var(--text-primary); cursor: pointer; transition: background var(--motion-fast); }
.image-zoom-close:hover { background: white; }
/* 危险操作确认：在保留明确警示的同时，与页面的卡片视觉保持一致。 */
.action-confirm-modal[hidden] { display: none; }
.action-confirm-modal { position: fixed; z-index: 1100; inset: 0; display: grid; place-items: center; padding: 20px; }
.action-confirm-backdrop { position: absolute; inset: 0; background: rgb(15 23 42 / 58%); backdrop-filter: blur(3px); }
.action-confirm-content { position: relative; z-index: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; width: min(440px, 100%); padding: 24px; border: 1px solid rgb(220 38 38 / 18%); border-radius: 16px; background: var(--surface); box-shadow: 0 24px 64px rgb(15 23 42 / 28%); animation: action-confirm-enter 160ms ease-out; }
.action-confirm-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgb(220 38 38 / 11%); color: #c2410c; font-weight: 800; font-size: 1.25rem; }
.action-confirm-copy h2 { margin: 0 0 4px; font-size: 1.15rem; }
.action-confirm-copy p { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.action-confirm-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.action-confirm-actions .btn { min-width: 88px; }
body:has(.action-confirm-modal:not([hidden])) { overflow: hidden; }
@keyframes action-confirm-enter { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 480px) { .action-confirm-content { padding: 20px; } .action-confirm-actions { flex-direction: column-reverse; } .action-confirm-actions .btn { width: 100%; } }
.attempt-selection { display: grid; gap: var(--space-3); }
.attempt-selection h4 { margin: 0; }
.attempt-selection .selection-canvas-wrap { max-width: 520px; }
.attempt-selection .selection-tools { margin-top: 0; }
.attempt-selection .selection-count { margin-right: auto; }
.attempt-diagnostic { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.teaching-panel { margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.section-title-row { justify-content: space-between; margin-bottom: 10px; }
h2 { margin-bottom: 0; font-size: 1.05rem; }
.panel-label { background: #e9ecef; color: var(--text-secondary); }
.panel-label-warm { background: var(--warning-soft); color: var(--warning); }
.panel-label-blue { background: var(--brand-soft); color: var(--brand); }
.empty-copy { margin-bottom: 0; color: var(--text-muted); }
.solution-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.solution-tab { padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-secondary); font-weight: 500; cursor: pointer; transition: all 0.2s; }
.solution-tab:hover { border-color: var(--brand); color: var(--brand); }
.solution-tab.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.solution-tab.htmx-request { opacity: 0.6; cursor: wait; }
.markdown-content { overflow-wrap: anywhere; }
.analysis-illustration { margin: 16px 0 0; padding: 10px; border-radius: 10px; background: var(--surface); }
.analysis-illustration img { display: block; width: 100%; max-height: 420px; object-fit: contain; border-radius: 6px; }
.analysis-illustration figcaption { margin-top: 8px; color: var(--text-muted); font-size: .85rem; }
.explanation-line { display: block; position: relative; width: 100%; padding: 6px 8px 6px 28px; border-left: 3px solid transparent; background: transparent; text-align: left; cursor: pointer; }
.explanation-line:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.explanation-line.is-selected { border-left-color: var(--accent); background: var(--surface-muted); }
.explanation-line.is-selected::before { content: "✓"; position: absolute; top: 8px; left: 8px; color: var(--accent); font-size: .85rem; font-weight: 700; }
.explanation-line.has-annotation { border-left-color: var(--warning); background: var(--warning-soft); }
.explanation-line.has-annotation::before { content: "●"; position: absolute; top: 8px; left: 8px; color: var(--warning); font-size: .72rem; font-weight: 700; }
.explanation-line.is-selected.has-annotation::before { content: "✓"; color: var(--accent); font-size: .85rem; }
/* 步骤消息会被脚本移入对应步骤；无步骤锚点的整份解析图片留在这里直接展示。 */
.annotation-layer { display: block; }
.line-annotation-slot { display: block; }
.annotation-message { display: block; position: relative; margin: 4px 0 12px 28px; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 6px; background: var(--surface); box-shadow: 0 2px 8px rgb(0 0 0 / 8%); }
.annotation-message summary { display: flex; align-items: center; gap: 8px; padding: 9px 10px; cursor: pointer; list-style: none; }
.annotation-message summary::-webkit-details-marker { display: none; }
.annotation-message summary::before { content: "▸"; color: var(--accent); }
.annotation-message[open] summary::before { content: "▾"; }
.annotation-marker { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--warning-soft); color: var(--warning); font-weight: 700; }
.annotation-preview { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annotation-status { margin-left: auto; color: var(--text-muted); font-size: .85rem; white-space: nowrap; }
.annotation-message-body { padding: 0 10px 10px; }
.annotation-actions { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border-light); }
.annotation-hint {
    margin: 0 0 16px;
    padding: 12px 16px;
    background: var(--brand-soft);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-control);
    color: var(--text-primary);
    font-size: .9rem;
    line-height: 1.5;
}
/* 桌面端将操作按钮固定在所选解析行右上角，并为完整按钮组预留空间，避免遮挡文字。 */
.annotation-compose { display: inline-flex; position: absolute; z-index: 2; top: 8px; right: 8px; gap: 8px; margin: 0; }
.annotation-compose[hidden] { display: none; }
.explanation-line.has-annotation-compose { min-height: 54px; padding-right: 280px; }
/* 批注位于按钮下方时恢复完整行宽，不继承正文为按钮预留的右侧空间。 */
.explanation-line.has-annotation-compose > .line-annotation-slot { margin-right: -272px; }
.annotation-request-error { margin: 8px 0 0; color: var(--danger); }
.full-question-action { display: flex; justify-content: flex-end; margin-top: 12px; }
.question-thread { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.question-thread-title { margin: 0 0 8px; font-size: .95rem; }
.question-thread[hidden] { display: none; }
.question-message { border-left-color: var(--brand); }
.question-message .annotation-marker { background: var(--brand-soft); color: var(--brand); }
.student-question { margin-bottom: 10px; color: var(--text-secondary); }
.question-dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-primary); box-shadow: 0 16px 48px rgb(0 0 0 / 22%); }
.question-dialog::backdrop { background: rgb(0 0 0 / 42%); }
.question-dialog form { display: grid; gap: 10px; padding: 20px; }
.question-dialog h3 { margin: 0; font-size: 1.05rem; }
.question-dialog label { color: var(--text-secondary); font-weight: 650; }
.question-dialog textarea { width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text-primary); }
@media (max-width: 600px) { .annotation-message { margin-left: 8px; margin-right: 0; } .annotation-compose { position: static; display: flex; width: 100%; margin-top: 8px; } .annotation-compose .btn { flex: 1; } .explanation-line.has-annotation-compose { min-height: 0; padding-right: 8px; } .explanation-line.has-annotation-compose > .line-annotation-slot { margin-right: 0; } .question-dialog form { padding: 16px; } }
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content p, .markdown-content ul, .markdown-content ol, .markdown-content blockquote, .markdown-content pre, .markdown-content table { margin: 0 0 12px; }
.markdown-content ul, .markdown-content ol { padding-left: 1.5rem; }
.markdown-content code { padding: 2px 5px; border-radius: 4px; background: var(--surface); font-family: Consolas, "Courier New", monospace; }
.markdown-content pre, .markdown-content .katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.markdown-content pre { padding: 12px; border-radius: 8px; background: var(--surface); }
.markdown-content pre code { padding: 0; background: transparent; }
.markdown-content blockquote { padding-left: 12px; border-left: 3px solid var(--border); color: var(--text-secondary); }
.markdown-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.markdown-content th, .markdown-content td { padding: 6px 10px; border: 1px solid var(--border); }
.source-note { display: block; margin-top: 8px; }
.inline-alert { margin: 0 20px 16px; padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); }
.message-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.card-menu { position: relative; }
.card-menu-trigger { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: none; border-radius: 6px; background: transparent; color: var(--text-muted); cursor: pointer; transition: background var(--motion-fast), color var(--motion-fast); }
.card-menu-trigger:hover { background: var(--surface-muted); color: var(--text-primary); }
.menu-dots { font-size: 20px; font-weight: 700; line-height: 1; }
.card-menu-dropdown { display: none; position: absolute; right: 0; bottom: 100%; margin-bottom: 4px; min-width: 160px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 4px 12px rgb(0 0 0 / 15%); z-index: 10; }
.card-menu.is-open .card-menu-dropdown { display: block; }
.card-menu-item { display: block; width: 100%; padding: 8px 12px; border: none; border-radius: 6px; background: transparent; color: var(--text-primary); font-size: .9rem; text-align: left; cursor: pointer; transition: background var(--motion-fast); }
.card-menu-item:hover { background: var(--surface-muted); }
.card-menu-item-danger { color: var(--danger); }
.card-menu-item-danger:hover { background: var(--danger-soft); }
.delete-confirm-dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text-primary); box-shadow: 0 16px 48px rgb(0 0 0 / 22%); }
.delete-confirm-dialog::backdrop { background: rgb(0 0 0 / 42%); }
.dialog-content { padding: 24px; }
.dialog-title { margin: 0 0 12px; font-size: 1.15rem; font-weight: 700; }
.dialog-message { margin: 0 0 20px; color: var(--text-secondary); line-height: 1.5; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c92a2a; }
.btn { min-height: 38px; padding: 7px 14px; border: 1px solid transparent; border-radius: var(--radius-control); cursor: pointer; transition: background var(--motion-fast), border-color var(--motion-fast); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: .875rem; }
.btn-primary { background: var(--brand); color: white; }
.btn-outline { border-color: var(--border); background: var(--surface); color: var(--text-secondary); }
.btn-outline-warm { border-color: #e8c66a; background: var(--warning-soft); color: var(--warning); }
.review-form { display: grid; gap: 8px; padding: 20px; }
.review-form label { color: var(--text-secondary); font-weight: 650; }

/* 反馈横幅：醒目提示用户联系作者。 */
.feedback-banner { max-width: 860px; margin: 0 auto 20px; padding: 14px 20px; background: var(--brand-soft); border: 1.5px solid var(--brand); border-radius: var(--radius-card); color: var(--brand); font-weight: 600; font-size: 15px; }
.feedback-banner-note { margin-left: 8px; font-weight: 400; color: var(--text-secondary); font-size: 13px; }

/* 个人设置和次数记录：使用行式布局，窄屏时自动堆叠。 */
.settings-panel { margin-bottom: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.admin-users-panel { padding: 0; }
.admin-users-summary { display: flex; align-items: center; gap: 10px; }
.admin-users-summary .page-subtitle { margin-bottom: 0; }
.admin-users-email-list { position: fixed; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.admin-users-table-wrap { width: 100%; }
.admin-users-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: clamp(.72rem, 1.35vw, .9rem); }
.admin-users-table th, .admin-users-table td { padding: 10px clamp(4px, .8vw, 12px); border-bottom: 1px solid var(--border); overflow-wrap: anywhere; text-align: left; }
.admin-users-table th { background: var(--surface-muted); color: var(--text-secondary); font-size: .85rem; }
.admin-users-sort-link { color: inherit; text-decoration: none; }
.admin-users-sort-link:hover { text-decoration: underline; }
.admin-users-table th:first-child { width: 22%; }
.admin-users-table th:nth-child(2), .admin-users-table th:nth-child(6) { width: 13%; }
.admin-users-table th:nth-child(3), .admin-users-table th:nth-child(4), .admin-users-table th:nth-child(5), .admin-users-table th:nth-child(7) { width: 7%; }
.admin-users-table th:nth-child(8) { width: 9%; }
.admin-users-table th:last-child { width: 8%; }
.admin-users-table td:nth-child(n+3) { text-align: center; }
.admin-users-table time { line-height: 1.4; }
.admin-users-table form { margin: 0; }
.admin-users-table .btn, .admin-users-table .status-badge { padding-right: 6px; padding-left: 6px; font-size: inherit; }
.admin-users-message { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.admin-users-table tbody tr:last-child td { border-bottom: 0; }
.admin-users-table tbody tr:hover { background: var(--surface-muted); }
.settings-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: 0; }
.settings-label, .settings-help { color: var(--text-secondary); }
.invite-link-row { align-items: flex-start; }
.invite-link-control { display: flex; align-items: flex-start; gap: 8px; min-width: 0; flex: 1; }
.invite-link-input { display: block; min-width: 0; flex: 1; min-height: 54px; resize: vertical; overflow-wrap: anywhere; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-muted); color: var(--text-primary); font: inherit; line-height: 1.45; word-break: break-all; }
.settings-help { margin: 10px 0 0; font-size: .9rem; }
.usage-ledger-list { display: grid; }
.usage-ledger-header, .usage-ledger-row { display: grid; grid-template-columns: minmax(140px, 1fr) 64px minmax(180px, 1.5fr) minmax(160px, 1.4fr); gap: 12px; align-items: center; }
.usage-ledger-header { padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: .85rem; }
.usage-ledger-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.usage-ledger-row:last-child { border-bottom: 0; }
.usage-ledger-row time { display: block; }
.usage-question-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(.65rem, 1.8vw, .82rem);  /* 显示不下时字体自动缩小 */
}
.usage-delta-positive { color: var(--success); }
.usage-delta-negative { color: var(--danger); }
.usage-empty { margin: 14px 0 0; }

/* 分页控件 */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.pagination-info {
  color: var(--text-secondary);
  font-size: .9rem;
}
.pagination-controls .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}


/* 知识点设置：参考分类管理的科目折叠和树形编辑布局。 */
.knowledge-settings { overflow: hidden; margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.knowledge-settings-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.knowledge-subject-list { padding: 12px; }
.knowledge-subject { margin-bottom: 12px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.knowledge-subject:last-child { margin-bottom: 0; }
.knowledge-subject > summary { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--surface-muted); cursor: pointer; list-style: none; }
.knowledge-subject > summary::-webkit-details-marker { display: none; }
.knowledge-subject > summary::before { content: "▸"; margin-right: 8px; color: var(--brand); }
.knowledge-subject[open] > summary::before { content: "▾"; }
.knowledge-subject-name { flex: 1; font-weight: 700; }
.knowledge-count, .knowledge-point-meta { color: var(--text-muted); font-size: .85rem; white-space: nowrap; }
.knowledge-point-counts { display: inline-grid; grid-template-columns: 52px 52px; align-items: center; gap: 8px; flex: 0 0 auto; font-size: .85rem; text-align: center; white-space: nowrap; }
.knowledge-tree-header { display: grid; grid-template-columns: minmax(0, 1fr) 52px 52px; gap: 8px; padding: 0 0 4px; color: var(--text-secondary); font-size: .85rem; text-align: center; }
.knowledge-tree-header span:first-child { text-align: left; }
.knowledge-count-unmastered { color: var(--danger); }
.knowledge-count-mastered { color: var(--success); }
.knowledge-tree { padding: 8px 12px; }
.knowledge-point { padding: 7px 0; border-bottom: 1px solid var(--border); }
.knowledge-point:last-child { border-bottom: 0; }
.knowledge-point-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.knowledge-point-name { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.knowledge-inline-form { display: flex; align-items: center; gap: 6px; }
.knowledge-inline-form input { width: min(180px, 25vw); min-width: 90px; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text-primary); }
.knowledge-inline-form .btn { min-height: 30px; padding: 4px 8px; font-size: .82rem; }
.knowledge-children { margin: 5px 0 0 18px; padding-left: 10px; border-left: 2px solid var(--border); }
.knowledge-point.is-inactive { opacity: .58; }
.knowledge-add-form { display: flex; gap: 8px; padding: 0 12px 12px; }
.knowledge-add-form input { min-width: 0; flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text-primary); }
.taxonomy-catalog { padding: 10px 16px 16px; }
.taxonomy-create-form { display: flex; gap: 8px; align-items: center; padding: 4px 0 14px; margin-bottom: 2px; border-bottom: 1px solid var(--border); }
/* 科目下拉框与右侧按钮保持一致的高度、圆角和交互反馈。 */
.taxonomy-create-form select { min-width: 112px; min-height: 38px; padding: 7px 36px 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-control); appearance: none; background-color: var(--surface); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236c757d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-position: right 12px center; background-repeat: no-repeat; color: var(--text-primary); font: inherit; cursor: pointer; transition: border-color var(--motion-fast), box-shadow var(--motion-fast); }
.taxonomy-create-form select:hover { border-color: var(--text-muted); }
.taxonomy-create-form select:focus-visible { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(13 110 253 / 18%); }
.taxonomy-create-form input { min-width: 0; flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text-primary); }
.taxonomy-fork-list { margin: 8px 12px 14px; border-top: 1px solid var(--border); }
.taxonomy-fork-title { padding: 14px 0 8px; color: var(--text-secondary); font-weight: 700; }
.taxonomy-fork-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.taxonomy-fork-info { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.taxonomy-fork-row .btn { flex: 0 0 auto; white-space: nowrap; }
.taxonomy-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.taxonomy-delete-form { display: inline-flex; margin: 0; }
.taxonomy-catalog-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.taxonomy-catalog-row:last-child { border-bottom: 0; }
.taxonomy-catalog-row > div, .taxonomy-catalog-actions { display: flex; align-items: center; gap: 12px; }
.outline-back { padding: 12px 16px 0; }
.outline-editor { padding: 16px; border-top: 1px solid var(--border); }
.outline-editor-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.outline-editor-header > div { display: flex; gap: 10px; align-items: baseline; }
.outline-textarea { display: block; width: 100%; min-height: 420px; box-sizing: border-box; resize: vertical; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-muted); color: var(--text-primary); font: 15px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
.outline-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.outline-preview { margin-top: 14px; padding: 12px; border: 1px solid var(--border); background: var(--surface-muted); }
.outline-preview-row { padding: 3px 0; white-space: pre-wrap; }
.outline-preview-text { margin: 8px 0 0; white-space: pre-wrap; overflow-x: auto; font: 14px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; }
.outline-error, .outline-success { margin-top: 12px; padding: 10px 12px; }
.outline-error { color: var(--danger); background: var(--danger-soft); }
.outline-success { color: var(--success); background: #e9f7ef; }
@media (max-width: 600px) { .knowledge-subject > summary { flex-wrap: wrap; } .taxonomy-actions { margin-left: 24px; } .knowledge-point-row { align-items: flex-start; flex-wrap: wrap; } .knowledge-point-counts { grid-template-columns: 42px 42px; } .knowledge-tree-header { grid-template-columns: minmax(0, 1fr) 42px 42px; } .knowledge-point-meta, .knowledge-point-counts { order: 2; } .knowledge-inline-form { order: 3; width: 100%; } .knowledge-inline-form input { flex: 1; width: auto; } }

.review-form textarea { width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--text-primary); }
.form-actions { margin-top: 8px; }
.import-status { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.import-status span { color: var(--text-secondary); }
.import-status.status-failed { border-color: var(--danger); background: var(--danger-soft); }
.candidate-grid { display: grid; gap: var(--space-4); }
.selection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.candidate-card { display: grid; gap: var(--space-3); padding: var(--space-4); border: 2px solid var(--border); border-radius: var(--radius-card); background: var(--surface); cursor: pointer; }
.candidate-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.candidate-card:focus-within { outline: 3px solid rgb(13 110 253 / 35%); outline-offset: 2px; }
.candidate-select { display: flex; align-items: center; gap: var(--space-2); }
.candidate-card img { display: block; width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--radius-control); background: var(--surface-muted); }
.candidate-text { max-height: 9rem; margin-bottom: 0; overflow: auto; white-space: pre-wrap; color: var(--text-secondary); }
input[type="file"] { width: 100%; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); }
.image-drop-zone { display: grid; gap: var(--space-2); padding: var(--space-4); border: 2px dashed var(--border); border-radius: var(--radius-control); background: var(--surface-muted); color: var(--text-secondary); transition: border-color var(--motion-fast), background var(--motion-fast); }
.image-drop-zone.is-dragging { border-color: var(--brand); background: var(--brand-soft); }
.image-drop-zone span { color: var(--text-muted); font-size: .9rem; }
.selected-image-list { display: grid; gap: var(--space-1); margin: 0; padding-left: 1.5rem; color: var(--text-secondary); }
.selected-image-list:empty { display: none; }
.inline-form-error { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); }
.manual-selection-toggle { margin: 0 0 var(--space-3); }
.manual-selection { display: grid; gap: var(--space-3); margin: 0 0 var(--space-5); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.manual-selection[hidden] { display: none; }
.selection-canvas-wrap { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); touch-action: none; }
.selection-image { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.selection-layer { position: absolute; inset: 0; cursor: crosshair; }
.selection-layer.is-selecting { background: rgb(13 110 253 / 4%); }
.selection-layer.is-resizing { cursor: move; }
.selection-box { position: absolute; border: 2px solid var(--brand); background: rgb(13 110 253 / 16%); pointer-events: none; border-radius: 4px; box-shadow: 0 2px 8px rgb(13 110 253 / 25%); transition: box-shadow 0.2s ease; }
.selection-box-drawing { border-style: dashed; background: rgb(13 110 253 / 24%); animation: selection-pulse 1s ease-in-out infinite; }
@keyframes selection-pulse {
  0%, 100% { border-color: var(--brand); }
  50% { border-color: rgb(13 110 253 / 60%); }
}
.selection-box button { pointer-events: auto; }
.selection-box button { position: absolute; top: -4px; right: -4px; min-width: 32px; min-height: 32px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; background: var(--danger); color: white; font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer; box-shadow: 0 2px 6px rgb(0 0 0 / 20%); transition: transform 0.15s ease, box-shadow 0.15s ease; z-index: 3; }
.selection-box button:hover, .selection-box button:focus-visible { transform: scale(1.1); box-shadow: 0 3px 10px rgb(0 0 0 / 30%); }
.selection-box button:active { transform: scale(0.95); }

/* 调整手柄样式 */
.resize-handle { position: absolute; pointer-events: auto; background: var(--brand); border: 2px solid white; box-shadow: 0 1px 4px rgb(0 0 0 / 25%); z-index: 2; }

/* 边缘手柄 */
.resize-handle-n, .resize-handle-s { width: 40px; height: 8px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.resize-handle-n { top: -4px; border-radius: 4px 4px 0 0; }
.resize-handle-s { bottom: -4px; border-radius: 0 0 4px 4px; }

.resize-handle-w, .resize-handle-e { width: 8px; height: 40px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.resize-handle-w { left: -4px; border-radius: 4px 0 0 4px; }
.resize-handle-e { right: -4px; border-radius: 0 4px 4px 0; }

/* 角落手柄 */
.resize-handle-nw, .resize-handle-ne, .resize-handle-sw, .resize-handle-se { width: 12px; height: 12px; border-radius: 50%; }
.resize-handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.resize-handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.resize-handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.resize-handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* 手柄悬停效果 */
.resize-handle:hover { background: var(--accent); transform: scale(1.15); }
.resize-handle:active { background: var(--brand); }
.selection-tools { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.selection-count { margin-right: auto; color: var(--text-secondary); }
@media (max-width: 600px) {
    /* 手机端导航折叠为汉堡菜单 */
    .nav-toggle { display: block; margin-left: auto; }
    .site-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 100; flex-direction: column; align-items: stretch; gap: 0; margin: 8px 12px 0; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / 15%); }
    .site-nav.is-open { display: flex; }
    .site-nav .header-action { margin: 0; padding: 10px 12px; border-radius: 6px; text-align: left; }
    .site-nav .header-action:hover { background: var(--surface-muted); }
    .site-nav form { margin: 0; }
    .site-nav form button { width: 100%; padding: 10px 12px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; }
    .site-nav form button:hover { background: var(--surface-muted); }
    .site-header { position: relative; }

    .usage-ledger-header { display: none; }
    .usage-ledger-row { grid-template-columns: 1fr auto; }
    .invite-link-row { flex-direction: column; gap: 8px; }
    .invite-link-control { width: 100%; }
    .invite-link-input { min-height: 72px; }
    .invite-link-control .btn { flex: 0 0 auto; min-height: 44px; }

    .usage-ledger-row > .usage-question-id, .usage-ledger-row > .meta-muted { grid-column: 1 / -1; }
    .site-header, .page-shell { padding-left: 12px; padding-right: 12px; }
    .header-caption { display: none; }
    .page-intro, .message-footer { align-items: flex-start; flex-direction: column; }
    .admin-users-summary { align-items: flex-start; flex-direction: column; }
    .student-dashboard { padding: 16px; }
    .student-dashboard-header { align-items: flex-start; }
    .student-total { padding-top: 3px; }
    .subject-counts { flex-wrap: wrap; }
    .subject-stat-item { font-size: .78rem; }
    .subject-stat-item b { font-size: .9rem; }

    /* 修复手机端题目卡片头部布局 */
    .message-header { align-items: flex-start; flex-direction: column; gap: 12px; }
    .message-meta { order: 1; width: 100%; }
    .message-header > .knowledge-tags { order: 2; width: 100%; }
    .message-header-right { order: 3; width: 100%; justify-content: space-between; }
    .question-number { white-space: nowrap; font-size: 1rem; }

    .message-body { padding: 14px; }
    .message-header, .message-footer { padding: 14px; }
    .message-footer > .card-menu { align-self: flex-end; } /* 移动端页脚纵向排列时，操作菜单保持右对齐 */
    .footer-actions { width: 100%; }
    .footer-actions .btn { flex: 1; }

    /* 手机端框选优化 */
    .manual-selection { padding: var(--space-3); }
    .section-title-row { flex-direction: column; align-items: flex-start; gap: 8px; }

    /* 诊断、解法的标签在手机端也保持在标题右侧，避免独占一行。 */
    .teaching-panel .section-title-row {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
    }
    .teaching-panel .section-title-row h2 { min-width: 0; }
    .selection-canvas-wrap { border-radius: 6px; }
    .selection-layer { cursor: none; /* 手机端隐藏鼠标指针，用手指操作 */ }
    .selection-box button {
        min-width: 40px;
        min-height: 40px;
        top: -6px;
        right: -6px;
        font-size: 24px;
    }
    /* 手机端将框选状态、次要操作和确认操作分成清晰的三行。 */
    .selection-tools {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-2);
    }
    /* Keep long crop confirmation text on a full-width row on narrow screens. */
    .selection-tools .btn {
        width: 100%;
        min-height: 44px; /* 增大触摸目标，符合移动端规范 */
        font-size: .95rem;
    }
    .selection-count {
        grid-column: 1 / -1;
        flex-basis: 100%;
        margin-right: 0;
        margin-bottom: 4px;
        text-align: center;
    }
    .selection-tools .btn-primary {
        grid-column: 1 / -1;
    }

    /* 手机端调整手柄增大 */
    .resize-handle-n, .resize-handle-s { width: 60px; height: 12px; }
    .resize-handle-n { top: -6px; }
    .resize-handle-s { bottom: -6px; }
    .resize-handle-w, .resize-handle-e { width: 12px; height: 60px; }
    .resize-handle-w { left: -6px; }
    .resize-handle-e { right: -6px; }
    .resize-handle-nw, .resize-handle-ne, .resize-handle-sw, .resize-handle-se { width: 18px; height: 18px; }
    .resize-handle-nw { top: -9px; left: -9px; }
    .resize-handle-ne { top: -9px; right: -9px; }
    .resize-handle-sw { bottom: -9px; left: -9px; }
    .resize-handle-se { bottom: -9px; right: -9px; }
}

/* 空状态引导：新用户首次访问时的录入引导 */
.empty-state { display: grid; place-items: center; gap: var(--space-4); min-height: 320px; padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); text-align: center; }
.empty-state-icon { font-size: 3.5rem; line-height: 1; }
.empty-state-title { margin: 0 0 var(--space-2); color: var(--text-primary); font-size: 1.25rem; font-weight: 700; }
.empty-state-description { margin: 0 0 var(--space-4); max-width: 420px; color: var(--text-secondary); line-height: 1.6; }
.empty-state-action { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 24px; border: 1px solid transparent; border-radius: var(--radius-control); background: var(--brand); color: white; font-weight: 650; text-decoration: none; transition: background var(--motion-fast); }
.empty-state-action:hover { background: #0b5ed7; }

/* 分页导航 */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.pagination-info { color: var(--text-secondary); font-size: .9rem; }
.pagination-controls { display: flex; gap: var(--space-2); }
.pagination-button { display: inline-flex; align-items: center; justify-content: center; min-width: 80px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); color: var(--brand); font-weight: 600; text-decoration: none; transition: all var(--motion-fast); cursor: pointer; }
.pagination-button:hover, .pagination-button:focus-visible { border-color: var(--brand); background: var(--brand-soft); }
.pagination-button-disabled { color: var(--text-muted); border-color: var(--border); background: var(--surface-muted); cursor: not-allowed; opacity: 0.6; }
.pagination-button-disabled:hover { border-color: var(--border); background: var(--surface-muted); }
.empty-state-action:focus-visible { outline: 3px solid rgb(13 110 253 / 35%); outline-offset: 2px; }
@media (max-width: 600px) { .empty-state { min-height: 280px; padding: var(--space-4); } .empty-state-icon { font-size: 3rem; } .empty-state-title { font-size: 1.1rem; } }

/* 账号筛选按钮过多时自动换行。 */
.admin-clean-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }

/* 诊断讨论：入口靠右，老师白色气泡、学生绿色气泡。 */
.question-chat-entry { display: flex; justify-content: flex-end; align-items: flex-start; gap: 8px; margin-top: 16px; }
.question-chat-entry [data-generate-full-image] { flex: 0 0 auto; white-space: nowrap; }
.question-chat-entry .attempt-chat { flex: 0 1 auto; width: auto; margin-top: 0; }
.attempt-chat > summary, .attempt-chat-trigger { width: fit-content; margin-left: auto; padding: 8px 14px; border: 1px solid #bfd9c1; border-radius: 6px; color: #247135; background: #f3faf3; cursor: pointer; font: inherit; }
.attempt-chat-trigger:disabled { cursor: not-allowed; opacity: .55; }
/* 展开时仍让两个入口紧挨在右侧，聊天面板另起一行。 */
.question-chat-entry:has(.attempt-chat[open]) { display: block; position: relative; }
.question-chat-entry:has(.attempt-chat[open]) [data-generate-full-image] { position: absolute; top: 0; right: 128px; z-index: 1; }
.question-chat-entry .attempt-chat[open] { width: 100%; }
.question-chat-entry .attempt-chat[open] > summary { min-width: 120px; box-sizing: border-box; margin-left: auto; }
.attempt-chat-window { margin-top: 10px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #ededed; }
.attempt-chat-heading { padding: 12px 14px; border-bottom: 1px solid #ddd; font-weight: 600; }
.attempt-chat-heading small { margin-left: 8px; font-weight: 400; color: #666; }
.attempt-chat-messages { height: 480px; max-height: 60vh; overflow-y: auto; padding: 16px 12px; }
.attempt-chat-row { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 16px; }
.attempt-chat-row--user { flex-direction: row-reverse; }
.attempt-chat-avatar { flex: 0 0 32px; height: 32px; display: grid; place-items: center; border-radius: 5px; background: #d8e5ed; color: #365263; font-size: 14px; }
.attempt-chat-row--user .attempt-chat-avatar { background: #d5eac8; color: #315e2c; }
.attempt-chat-message { position: relative; min-width: 0; max-width: 82%; padding: 9px 12px; border-radius: 6px; background: white; overflow-wrap: anywhere; }
.attempt-chat-message::before { content: ""; position: absolute; top: 12px; left: -6px; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 6px solid white; }
.attempt-chat-row--user .attempt-chat-message { background: #95ec69; }
.attempt-chat-row--user .attempt-chat-message::before { left: auto; right: -6px; border-right: 0; border-left: 6px solid #95ec69; }
.attempt-chat-message .markdown-content > :first-child { margin-top: 0; }
.attempt-chat-message .markdown-content > :last-child { margin-bottom: 0; }
.attempt-chat-text { white-space: pre-wrap; }
.attempt-chat-form { padding: 12px; background: #fafafa; }
/* 有聊天消息时才添加分隔线，空聊天直接显示输入框。 */
.attempt-chat-messages + .attempt-chat-form { border-top: 1px solid #ddd; }
.attempt-chat-form textarea { box-sizing: border-box; width: 100%; resize: vertical; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font: inherit; }
.attempt-chat-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 8px; }
.attempt-chat-send { background: #07a947; color: white; border: 0; padding: 7px 22px; }
.attempt-chat-error { color: #a32c20; margin: 8px 0; font-size: 14px; }

.attempt-chat .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* 固定口袋适应手机屏幕，列表独立滚动，手柄支持触屏排序。 */
.export-pocket { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 80; width: min(360px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 28px rgb(0 0 0 / 20%); }
.export-pocket[hidden], #export-pocket-body[hidden] { display: none; }
.export-pocket-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 14px; border: 0; background: transparent; color: var(--text-primary); cursor: pointer; }
.export-pocket-toggle > span:last-child { font-size: 12px; }
#export-pocket-body { padding: 0 12px 12px; }
#export-pocket-body p { font-size: 12px; margin: 8px 0; }
.export-pocket-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.export-pocket ol { margin: 0; padding: 0; list-style: none; max-height: 35vh; overflow-y: auto; overscroll-behavior: contain; }
.export-pocket li { display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--border); background: var(--surface); }
.export-pocket li > span { flex: 1; overflow-wrap: anywhere; }
.export-pocket li button { min-width: 44px; min-height: 44px; padding: 8px; border: 0; background: transparent; color: var(--text-primary); cursor: pointer; }
.export-pocket .export-drag-handle { touch-action: none; user-select: none; cursor: grab; }
.export-pocket li.is-dragging { background: var(--surface-muted); outline: 2px solid var(--brand); outline-offset: -2px; }
