:root {
  --bg: #f3f7fb;
  --card: #ffffff;
  --text: #13283b;
  --line: #d4dde8;
  --accent: #0b6ea8;
  --danger: #a3122b;
}

.cb-option-feedback {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f7fb;
  border: 1px solid #d8e2ef;
  color: #253449;
  line-height: 1.5;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

.muted-text {
  color: #5f7388;
  font-size: 12px;
  margin-top: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #d9ebff, #f3f7fb 55%);
}

h1, h2, h3 { margin: 0 0 8px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title-wrap h1 {
  margin: 0;
}

.topbar-title-wrap #captureScrollBtn {
  margin-top: 0;
  width: auto;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.top-actions > * {
  margin-top: 0;
}

.top-actions label {
  display: inline-block;
  margin: 0;
  white-space: nowrap;
}

.top-actions button {
  width: auto;
  white-space: nowrap;
  padding: 8px 14px;
}

.top-utility-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.top-utility-actions button {
  margin-top: 0;
}

.top-manage-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
}

#subjectSelect,
#chapterManageSubjectSelect {
  width: clamp(180px, 17vw, 260px);
  min-width: 160px;
  max-width: 260px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  background: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.top-link:hover {
  border-color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
  padding: 14px;
}

.sidebar, .content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.single-column {
  grid-template-columns: 1fr;
}

body[data-page="chapters"] .chapter-manage-layout {
  grid-template-columns: minmax(320px, 38%) minmax(420px, 62%);
  align-items: stretch;
  height: calc(100dvh - 84px);
  min-height: calc(100dvh - 84px);
  overflow: hidden;
}

body[data-page="chapters"] {
  height: 100dvh;
  overflow: hidden;
}

body[data-page="chapters"] .chapter-manage-tree-panel,
body[data-page="chapters"] .chapter-manage-side > .panel {
  min-height: 220px;
}

body[data-page="chapters"] .chapter-manage-tree-panel {
  display: flex;
  flex-direction: column;
}

body[data-page="chapters"] .chapter-manage-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
}

body[data-page="chapters"] .chapter-manage-edit-panel,
body[data-page="chapters"] .chapter-manage-create-panel {
  flex: 0 0 auto;
}

body[data-page="chapters"] .chapter-manage-panel-head p {
  margin: 2px 0 0;
  color: #537089;
  font-size: 13px;
}

body[data-page="chapters"] .chapter-manage-tree-list {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  margin-top: 6px;
  min-height: 0;
  overflow: auto;
}

body[data-page="chapters"] .chapter-manage-tree-item {
  cursor: pointer;
  border-left: 3px solid transparent;
  padding: 4px 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

body[data-page="chapters"] .chapter-manage-tree-item:hover {
  background: #f3f9ff;
}

body[data-page="chapters"] .chapter-manage-tree-item.active {
  background: #dff1ff;
  border-left-color: #0a5f90;
}

body[data-page="chapters"] .chapter-manage-tree-item:focus {
  outline: 2px solid rgba(11, 110, 168, 0.3);
  outline-offset: -2px;
}

body[data-page="chapters"] .chapter-manage-tree-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 26px;
}

body[data-page="chapters"] .chapter-manage-tree-title {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-page="chapters"] .chapter-manage-tree-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

body[data-page="chapters"] .chapter-manage-tree-meta-inline {
  color: #5b7388;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

body[data-page="chapters"] .chapter-manage-compact-tag {
  margin-left: 0;
  padding: 0 5px;
  font-size: 11px;
}

body[data-page="chapters"] .chapter-manage-empty {
  margin-top: 10px;
  border: 1px dashed #b8cbdd;
  background: #f8fbff;
  border-radius: 8px;
  padding: 10px;
  color: #4f6579;
}

body[data-page="chapters"] .chapter-manage-actions-row {
  grid-template-columns: 1fr 1fr;
}

body[data-page="chapters"] .chapter-manage-actions-row button {
  margin-top: 0;
}

.chapter-tree-select {
  position: relative;
  min-width: 220px;
  max-width: 320px;
  flex: 1 1 240px;
}

.chapter-tree-toggle {
  margin-top: 0;
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

#chapterTreeSelectedLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-tree-caret {
  color: #49657e;
}

.chapter-tree-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 4;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(8, 30, 55, 0.14);
}

.chapter-tree-dropdown-body {
  max-height: 320px;
  overflow: auto;
  padding: 6px;
}

.chapter-tree-empty {
  color: #5f7386;
  padding: 8px;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0;
}

.tree-toggle-btn {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  margin-top: 0;
  padding: 5px 0;
  line-height: 1;
  text-align: center;
}

.tree-toggle-spacer {
  width: 28px;
  flex: 0 0 28px;
}

.tree-select-btn {
  margin-top: 0;
  text-align: left;
  background: #fff;
}

.tree-select-btn.active {
  background: #e7f4ff;
  border-color: #9dccee;
}

#mainLearningView,
#materialEditorView {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-top: 6px;
  font-size: 14px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

button {
  cursor: pointer;
  background: #fff;
}

button:hover { border-color: var(--accent); }
button:disabled {
  background: #f0f3f7;
  color: #6c7b88;
  border-color: #d9e1ea;
  cursor: not-allowed;
}

.row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.export-row > button {
  width: auto;
}

.export-row-knowledge .knowledge-export-btn {
  width: auto;
  max-width: 100%;
}

.status-box {
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px;
  background: #f8fbff;
  white-space: pre-wrap;
}

.status-box.error {
  border-color: #f0b8c3;
  background: #fff7f9;
  color: #7d1425;
}

.status-box.success {
  border-color: #b9dfc4;
  background: #f6fff8;
  color: #1f5f34;
}

.error-detail-panel {
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid #f0b8c3;
  background: #fff7f9;
  padding: 10px;
}

.error-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.error-detail-header button {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
}

.material-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.material-editor-header button {
  width: auto;
  margin-top: 0;
}

.material-editor-subtitle {
  margin-top: 6px;
  color: #49657e;
  font-size: 13px;
}

#generationErrorText {
  margin-top: 8px;
  min-height: 140px;
  resize: vertical;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.list {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 260px;
  overflow: auto;
}

.list-item {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  white-space: pre-wrap;
}

.list-item:last-child { border-bottom: none; }
.list-item.active { background: #e7f4ff; }

.tag {
  display: inline-block;
  background: #edf6ff;
  border: 1px solid #c6e2f7;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 12px;
  margin-left: 6px;
}

.error { color: var(--danger); }

.learning-tabs {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab-btn {
  width: auto;
  min-width: 120px;
}

.tab-btn.active {
  background: #e7f4ff;
  border-color: #9dccee;
  color: #0a4f78;
}

.learning-page {
  display: none;
}

.learning-page.active {
  display: block;
}

#learningPagePoints {
  min-height: calc(100vh - 150px);
  padding-bottom: 90px;
}

#learningPageKnowledge {
  min-height: calc(100vh - 150px);
  padding-bottom: 90px;
}

.knowledge-layout {
  margin-top: 8px;
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 62%) minmax(420px, 38%);
  gap: 4px;
  align-items: stretch;
  min-height: calc(100vh - 142px);
}

.knowledge-main {
  min-width: 0;
}

.knowledge-main .word-doc {
  max-width: none;
  width: 100%;
}

.points-layout {
  margin-top: 8px;
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 62%) minmax(420px, 38%);
  gap: 4px;
  align-items: stretch;
  min-height: calc(100vh - 142px);
}

.points-main {
  min-width: 0;
}

.points-main .word-doc,
.points-main .point-card {
  max-width: none;
  width: 100%;
}

.point-annotation-side-panel {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  height: calc(100vh - 176px);
  min-height: 520px;
  box-sizing: border-box;
  padding-bottom: 78px;
}

.point-annotation-meta {
  color: #4f6579;
  font-size: 13px;
}

.point-annotation-selected {
  min-height: 64px;
  border: 1px dashed #adc2d6;
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.point-annotation-input {
  min-height: 170px;
  flex: 1;
}

.point-annotation-style-row {
  margin-top: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.point-annotation-style-row button,
.point-annotation-style-row select,
.point-annotation-style-row input {
  margin-top: 0;
  width: 100%;
}

.point-annotation-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  padding: 10px;
  background: #fff;
  font-size: 15px;
  line-height: 1.7;
}

.point-annotation-editor:focus {
  outline: 2px solid rgba(11, 110, 168, 0.22);
  border-color: #8cbad7;
}

.point-annotation-editor[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: #8ca0b3;
}

.point-annotation-feedback {
  margin-top: 0;
  background: #f8fbff;
  border: 1px solid #d4dde8;
  border-radius: 8px;
  padding: 8px;
  min-height: 72px;
  white-space: pre-wrap;
}

.point-annotation-actions {
  margin-top: auto;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  transition: box-shadow 120ms ease;
}

.point-annotation-actions.point-annotation-actions-floating {
  position: fixed;
  bottom: 0;
  z-index: 12;
  margin-top: 0;
  padding: 10px 12px 12px;
  border: 1px solid #c6d3e0;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 -10px 24px rgba(8, 30, 55, 0.16);
}

.point-card {
  position: relative;
}

.point-card.has-point-annotation::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d9534f;
}

.point-card.has-point-highlight:not(.has-point-annotation)::after {
  background: #e2b300;
}

.point-selection-highlight {
  background: rgba(214, 235, 254, 0.85);
}

.point-annotation-mark {
  background: rgba(255, 239, 160, 0.54);
  border-radius: 2px;
  cursor: pointer;
  padding: 0 1px;
  transition: background-color 120ms ease, opacity 120ms ease;
  opacity: 0.76;
}

.point-annotation-mark:hover {
  opacity: 0.94;
}

.point-annotation-mark.point-annotation-mark-active {
  background: #ffd34f;
  box-shadow: 0 0 0 1px #e7b52f inset;
  opacity: 1;
}

.teaching-annotation-mark {
  background: rgba(255, 239, 160, 0.54);
  border-radius: 2px;
  cursor: pointer;
  padding: 0 1px;
  transition: background-color 120ms ease, opacity 120ms ease;
  opacity: 0.76;
}

.teaching-annotation-mark:hover {
  opacity: 0.94;
}

.teaching-annotation-mark.teaching-annotation-mark-active {
  background: #ffd34f;
  box-shadow: 0 0 0 1px #e7b52f inset;
  opacity: 1;
}

.point-highlight-mark {
  background: #fff3a8;
  border-radius: 2px;
  cursor: pointer;
  padding: 0 1px;
  transition: background-color 120ms ease;
}

.point-highlight-mark:hover {
  background: #ffe77b;
}

.teaching-highlight-mark {
  background: #fff3a8;
  border-radius: 2px;
  cursor: pointer;
  padding: 0 1px;
  transition: background-color 120ms ease;
}

.teaching-highlight-mark:hover {
  background: #ffe77b;
}

.point-quick-highlight-btn {
  position: fixed;
  z-index: 24;
  width: auto;
  min-width: 58px;
  margin-top: 0;
  padding: 6px 10px;
  border: 1px solid #9bbd3d;
  border-radius: 8px;
  background: #fff7c2;
  color: #3d4d0e;
  box-shadow: 0 8px 18px rgba(20, 34, 56, 0.22);
}

.point-quick-highlight-btn:hover {
  border-color: #7ea022;
  background: #ffef9f;
}

.point-quick-annotate-btn {
  position: fixed;
  z-index: 24;
  width: auto;
  min-width: 72px;
  margin-top: 0;
  padding: 6px 10px;
  border: 1px solid #8cbad7;
  border-radius: 8px;
  background: #f1f8ff;
  color: #0a4f78;
  box-shadow: 0 8px 18px rgba(20, 34, 56, 0.22);
}

.point-quick-annotate-btn:hover {
  border-color: #5d9fca;
  background: #e4f1ff;
}

.point-annotation-history-layout {
  grid-template-columns: 1fr;
}

.point-annotation-history-panel {
  max-width: 980px;
}

.point-annotation-history-meta {
  color: #4f6579;
  margin-bottom: 8px;
}

.point-annotation-history-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.point-annotation-history-item .speaker-tag {
  display: inline-block;
  width: fit-content;
  border: 1px solid #9dccee;
  border-radius: 999px;
  padding: 2px 8px;
  color: #0a4f78;
  background: #edf6ff;
  font-size: 12px;
}

.focus-summary-panel {
  margin-top: 12px;
}

#focusSummaryInput {
  min-height: 220px;
}

.note-side-panel {
  position: relative;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.note-meta {
  color: #4f6579;
  font-size: 13px;
}

.note-style-row {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 2fr;
  gap: 8px;
  align-items: center;
}

.note-style-row button,
.note-style-row select,
.note-style-row input {
  margin-top: 0;
}

.note-editor-rich {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 260px;
  height: 260px;
  overflow: auto;
  padding: 10px;
  background: #fff;
  font-size: 15px;
  line-height: 1.7;
}

.note-editor-rich:focus {
  outline: 2px solid rgba(11, 110, 168, 0.22);
  border-color: #8cbad7;
}

.note-editor-rich:empty::before {
  content: attr(data-placeholder);
  color: #8ca0b3;
}

.note-editor-rich img {
  max-width: 100%;
  border-radius: 6px;
  margin: 6px 0;
}

.note-checking-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(243, 247, 251, 0.82);
  color: #0a4f78;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.note-image-input-hidden {
  display: none !important;
}

#noteFeedback {
  margin-top: 8px;
  background: #f8fbff;
  border: 1px solid #d4dde8;
  border-radius: 8px;
  padding: 8px;
  min-height: 72px;
  white-space: pre-wrap;
}

.note-floating-actions {
  position: sticky;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-self: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid #bed2e5;
  background: #fff;
  box-shadow: 0 10px 20px rgba(8, 30, 55, 0.16);
}

.note-floating-actions button {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
}

.note-versions-list {
  max-height: 360px;
}

.note-version-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-version-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.note-version-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: #2f4558;
}

.note-version-op {
  font-weight: 700;
  color: #0a4f78;
}

.note-version-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.note-version-actions button {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
}

.note-version-detail {
  border: 1px solid #d4dde8;
  border-radius: 8px;
  padding: 8px;
  background: #f8fbff;
}

.note-version-detail pre {
  margin: 4px 0 0;
}

.word-doc {
  margin-top: 10px;
  border: 1px solid #cfd8e4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(8, 30, 55, 0.08);
  padding: 24px 28px;
  max-width: 900px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  line-height: 1.85;
}

.word-doc h1, .word-doc h2, .word-doc h3 {
  margin-top: 0;
}

.doc-body {
  white-space: pre-wrap;
}

.qa-item {
  margin-top: 14px;
  border-top: 1px solid #e7edf5;
  padding-top: 12px;
  position: relative;
  overflow: hidden;
}

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

.cb-card-title {
  font-weight: 700;
  color: #1f3650;
}

.cb-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cb-card-actions button {
  margin-top: 0;
  width: auto;
  padding: 6px 10px;
}

.point-card {
  margin-top: 10px;
  border: 1px solid #cfd8e4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(8, 30, 55, 0.08);
  padding: 16px 20px;
  max-width: 900px;
}

.point-title {
  font-weight: 700;
  line-height: 1.6;
}

.point-exp {
  margin-top: 8px;
  color: #2f4558;
  line-height: 1.8;
  white-space: pre-wrap;
}

.question-prompt {
  white-space: pre-wrap;
}

.cb-rich-html {
  line-height: 1.7;
}

.cb-rich-html p {
  margin: 0 0 8px;
}

.cb-rich-html p:last-child {
  margin-bottom: 0;
}

.cb-rich-html img {
  display: block;
  max-width: min(720px, 100%);
  width: auto;
  height: auto;
  margin: 8px 0;
  border-radius: 6px;
}

.cb-rich-html table {
  border-collapse: collapse;
  margin: 10px 0;
  max-width: 100%;
  width: max-content;
}

.cb-rich-html th,
.cb-rich-html td {
  border: 1px solid #a7bccf;
  padding: 6px 10px;
  vertical-align: top;
}

.cb-rich-html table thead th {
  background: #eef4fa;
}

.mcq-options {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mcq-option-btn {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  margin-top: 0;
  background: #f8fbff;
  border: 1px solid #c8dceb;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.mcq-option-btn:hover {
  border-color: #7fb1d3;
  background: #eef7ff;
}

.mcq-option-btn:active {
  transform: translateY(1px);
}

.mcq-option-btn:disabled {
  cursor: wait;
}

.mcq-option-label {
  width: 22px;
  font-weight: 700;
  color: #0b6ea8;
  flex-shrink: 0;
}

.mcq-option-btn.wrong {
  border-color: #d94c5f;
  background: #fff1f3;
  color: #8e1026;
}

.mcq-option-btn.correct {
  border-color: #2f9e44;
  background: #effcf2;
  color: #1f6f31;
}

.answer-result {
  margin-top: 8px;
  min-height: 22px;
}

.answer-result .success {
  color: #1f7a43;
  font-weight: 600;
}

.recheck-card {
  margin-top: 12px;
}

.recheck-next-wrap {
  margin-top: 14px;
}

.recheck-next-btn {
  background: #fff8d8;
  border-color: #f0cf5b;
  color: #7a5500;
  font-weight: 700;
}

.recheck-next-btn:hover {
  border-color: #d9af1d;
  background: #fff1b8;
}

.recheck-failure-hint {
  margin: 10px 0 14px;
}

.recheck-failure-btn {
  background: #fff3f3;
  border-color: #dd8e8e;
  color: #8d2424;
  font-weight: 700;
}

.recheck-failure-btn:hover {
  background: #ffe8e8;
  border-color: #cf6f6f;
}

.wrong-card {
  border-width: 2px;
}

.wrong-card--active {
  box-shadow: 0 0 0 3px rgba(11, 110, 168, 0.18), 0 8px 22px rgba(8, 30, 55, 0.08);
}

.wrong-card--unresolved {
  border-color: #dc5a5a;
  background: #fff6f6;
}

.wrong-card--in-progress {
  border-color: #c79b43;
  background: #fff9ed;
}

.wrong-card--resolved {
  border-color: #55a86d;
  background: #f2fbf4;
}

.wrong-card-meta {
  margin: 8px 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wrong-status-pill,
.wrong-progress-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

.wrong-status-pill {
  background: #eef4fa;
  color: #28465f;
}

.wrong-progress-pill {
  background: #f2f4e8;
  color: #5b4a18;
}

.wrong-action--danger {
  background: #ffe8e8;
  border-color: #df7d7d;
  color: #8e1f1f;
  font-weight: 700;
}

.wrong-action--danger:hover {
  background: #ffdede;
  border-color: #cf6161;
}

.wrong-action--progress {
  background: #fff5d9;
  border-color: #e2ba5d;
  color: #745100;
  font-weight: 700;
}

.wrong-action--progress:hover {
  background: #ffefc0;
  border-color: #cb9a2f;
}

.wrong-action--resolved {
  background: #e8f8ec;
  border-color: #74bc8a;
  color: #1f6d39;
  font-weight: 700;
}

.wrong-action--resolved:hover {
  background: #dff3e4;
  border-color: #58a470;
}

.wrong-detail-card {
  margin-top: 12px;
}

.wrong-detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.wrong-detail-back-btn {
  margin-top: 0;
  width: auto;
  background: #f6f9fc;
}

.wrong-detail-meta {
  margin-bottom: 8px;
  color: #314e64;
}

.wrong-review-layout {
  padding-top: 10px;
}

.wrong-review-panel {
  max-width: 980px;
  margin: 0 auto;
}

.wrong-review-error {
  margin-top: 8px;
  border: 1px solid #e3a4ac;
  border-radius: 8px;
  background: #fff4f5;
  color: #822333;
  padding: 10px 12px;
  line-height: 1.6;
}

.wrong-round-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.wrong-round-status {
  font-size: 12px;
  color: #576d7f;
}

.wrong-round-answer,
.wrong-round-analysis {
  margin-top: 8px;
}

.wrong-round-attempts {
  margin-top: 10px;
}

.wrong-attempt-empty {
  margin-top: 6px;
  color: #5a6f81;
  font-size: 13px;
}

.wrong-attempt-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wrong-attempt-item {
  border-radius: 8px;
  border: 1px solid #d8e1ea;
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
}

.wrong-attempt-item.correct {
  border-color: #78bf8d;
  background: #f3fbf5;
  color: #1d6b36;
}

.wrong-attempt-item.wrong {
  border-color: #e2a0a8;
  background: #fff5f6;
  color: #8b2132;
}

.failed-question-panel {
  margin-top: 12px;
}

.failed-item {
  margin-top: 12px;
  border: 1px solid #e4c8cd;
  border-radius: 10px;
  background: #fff7f8;
  box-shadow: 0 6px 14px rgba(60, 15, 20, 0.06);
  padding: 12px 14px;
}

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

.failed-tag {
  display: inline-flex;
  align-items: center;
  background: #a3122b;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}

.failed-summary {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.failed-summary-tag {
  background: #6c1f2f;
}

.failed-meta {
  margin-top: 4px;
  color: #5a3040;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.failed-reason {
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid #ecc2c9;
  background: #fff;
  padding: 8px 10px;
  color: #7c1c2f;
  white-space: pre-wrap;
  word-break: break-word;
}

.failed-block {
  margin-top: 8px;
}

.failed-block strong {
  display: block;
  margin-bottom: 4px;
}

.failed-block pre {
  margin: 0;
  background: #fff;
  border: 1px solid #efcfd4;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confetti-fall 1s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-12px) rotate(0deg);
    opacity: 0.95;
  }
  100% {
    transform: translateY(170px) rotate(520deg);
    opacity: 0;
  }
}

.asset-item {
  display: grid;
  grid-template-columns: auto 88px 1fr auto;
  gap: 10px;
  align-items: center;
  cursor: default;
}

.asset-item.dragging {
  opacity: 0.55;
}

.asset-item.drag-over {
  border: 1px dashed var(--accent);
  background: #eef7ff;
}

.asset-drag-handle {
  font-size: 12px;
  color: #49657e;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  user-select: none;
  cursor: grab;
}

.asset-item.dragging .asset-drag-handle {
  cursor: grabbing;
}

.asset-thumb {
  width: 88px;
  height: 66px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef4fa;
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.asset-thumb:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(8, 30, 55, 0.16);
}

.asset-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asset-actions {
  display: grid;
  grid-template-columns: minmax(52px, auto);
  gap: 6px;
}

pre {
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f9fcff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 30, 0.35);
  display: grid;
  place-items: center;
}

.modal.hidden { display: none; }

.modal-content {
  width: min(680px, 90vw);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 16px;
}

#recheckContinueText {
  margin-top: 6px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.recheck-fail-modal-content {
  width: min(860px, 95vw);
  max-height: 84vh;
  overflow: auto;
}

.chapter-asset-preview-content {
  width: min(980px, 95vw);
  max-height: 90vh;
  overflow: auto;
}

.chapter-asset-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chapter-asset-preview-header button {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
}

.chapter-asset-preview-meta {
  margin-top: 8px;
  color: #49657e;
  font-size: 13px;
}

.chapter-asset-preview-image-wrap {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f5f9fd;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.chapter-asset-preview-image {
  max-width: 100%;
  max-height: calc(90vh - 220px);
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #d7e2ed;
  background: #fff;
}

.recheck-fail-summary {
  margin-bottom: 10px;
}

.recheck-fail-copy-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recheck-fail-copy-text {
  margin-top: 8px;
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  background: #f9fcff;
  resize: vertical;
}

.recheck-fail-meta {
  margin-top: 6px;
  color: #5f3340;
  font-size: 13px;
}

.recheck-fail-item {
  margin-top: 10px;
  border: 1px solid #e4c8cd;
  border-radius: 10px;
  background: #fff7f8;
  box-shadow: 0 6px 14px rgba(60, 15, 20, 0.06);
  padding: 12px 14px;
}

.recheck-fail-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.recheck-fail-rules {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recheck-fail-rule {
  background: #6c1f2f;
}

.recheck-fail-block {
  margin-top: 8px;
}

.recheck-fail-block strong {
  display: block;
  margin-bottom: 4px;
}

.recheck-fail-block pre {
  margin: 0;
  background: #fff;
  border: 1px solid #efcfd4;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.capture-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

.capture-mask {
  position: absolute;
  background: rgba(10, 24, 38, 0.44);
  pointer-events: none;
}

.capture-valid-area {
  position: absolute;
  border: 2px solid rgba(23, 127, 195, 0.92);
  background: rgba(23, 127, 195, 0.14);
  pointer-events: none;
}

.capture-valid-mask {
  position: absolute;
  background: rgba(10, 24, 38, 0.36);
  pointer-events: none;
}

.capture-selection {
  position: absolute;
  border: 2px dashed #2a84bf;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0);
  pointer-events: none;
}

.capture-points {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.capture-point {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #0b6ea8;
  box-shadow: 0 2px 8px rgba(8, 30, 55, 0.35);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: move;
  z-index: 2;
}

.capture-point-active {
  background: #e56f0a;
}

.capture-point-label {
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  min-width: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(14, 33, 51, 0.92);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.capture-tip {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 33, 51, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  line-height: 1.2;
  pointer-events: none;
}

.capture-toolbar {
  position: absolute;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #a8c6de;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 20px rgba(8, 30, 55, 0.2);
  pointer-events: auto;
}

.capture-toolbar button {
  width: auto;
  margin-top: 0;
  padding: 6px 10px;
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    align-items: stretch;
  }
  .topbar-title-wrap {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-title-wrap #captureScrollBtn {
    width: auto;
    min-width: 110px;
  }
  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-width: unset;
  }
  .top-actions label {
    grid-column: 1 / -1;
  }
  .top-utility-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .top-manage-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  #subjectSelect,
  #chapterManageSubjectSelect,
  .chapter-tree-select {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .top-actions button,
  .top-link {
    width: 100%;
  }
  .layout { grid-template-columns: 1fr; }
  body[data-page="chapters"] .chapter-manage-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
    overflow: visible;
  }
  body[data-page="chapters"] {
    height: auto;
    overflow: auto;
  }
  body[data-page="chapters"] .chapter-manage-tree-list {
    max-height: none;
    min-height: 320px;
  }
  body[data-page="chapters"] .chapter-manage-actions-row {
    grid-template-columns: 1fr;
  }
  .row { grid-template-columns: 1fr 1fr; }
  .export-row { flex-direction: column; }
  .export-row > button {
    width: 100%;
  }
  .export-row-knowledge .knowledge-export-btn {
    width: 100%;
  }
  .knowledge-layout {
    grid-template-columns: 1fr;
  }
  .points-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  #learningPagePoints {
    padding-bottom: 0;
  }
  #learningPageKnowledge {
    padding-bottom: 0;
  }
  .point-annotation-side-panel {
    position: static;
    height: auto;
    min-height: auto;
    padding-bottom: 0;
  }
  .point-annotation-style-row {
    grid-template-columns: 1fr 1fr;
  }
  .point-annotation-actions.point-annotation-actions-floating {
    position: static;
    width: auto !important;
    left: auto !important;
    bottom: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: none;
    padding: 0;
  }
  .note-style-row {
    grid-template-columns: 1fr 1fr;
  }
  .material-editor-header {
    flex-direction: column;
    align-items: stretch;
  }
  .material-editor-header button {
    width: 100%;
  }
  .asset-item { grid-template-columns: auto 72px 1fr; }
  .asset-thumb { width: 72px; height: 54px; }
  .asset-actions { grid-column: 1 / -1; grid-template-columns: 1fr; }
  .chapter-asset-preview-content {
    width: min(95vw, 95vw);
  }
  .chapter-asset-preview-image {
    max-height: calc(90vh - 250px);
  }
}
