/* ============ 管理后台样式 ============ */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: #F0EDE8;
  color: #1C2521;
  font-size: 14px;
  line-height: 1.5;
}

.admin-layout { display: flex; min-height: 100vh; }

/* Sidebar nav */
.admin-nav {
  width: 220px; flex-shrink: 0;
  background: #1F4D3A;
  color: white;
  display: flex; flex-direction: column;
  padding: 0;
  position: sticky; top: 0; height: 100vh;
}
.admin-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-brand-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.3px;
}
.admin-brand-sub {
  font-size: 11px; color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 1.5px;
}
.admin-nav-items { padding: 12px 10px; flex: 1; }
.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  width: 100%; text-align: left;
  border: none; background: none; font-family: inherit;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.admin-nav-item.active { background: rgba(255,255,255,0.15); color: white; }
.admin-nav-icon { font-size: 16px; width: 20px; text-align: center; }
.admin-nav-footer {
  padding: 14px 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.admin-back-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px; color: rgba(255,255,255,0.5);
  cursor: pointer; background: none; border: none;
  font-family: inherit; width: 100%;
  transition: color 0.15s;
}
.admin-back-btn:hover { color: white; }

/* Main content */
.admin-main {
  flex: 1; padding: 28px;
  overflow-y: auto;
}
.admin-page { display: none; }
.admin-page.active { display: block; }

.admin-page-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 24px; font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.3px;
}
.admin-page-sub { font-size: 13px; color: #8B958F; margin: 0 0 24px; }

/* Cards */
.admin-card {
  background: white;
  border: 1px solid #E5DFD3;
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(28,37,33,0.04);
}
.admin-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.admin-card-title { font-weight: 600; font-size: 15px; }

/* Buttons */
.btn-primary {
  padding: 9px 18px;
  background: #1F4D3A; color: white;
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-secondary {
  padding: 9px 18px;
  background: transparent; color: #4A5853;
  border: 1px solid #E5DFD3; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: #1F4D3A; color: #1F4D3A; }
.btn-danger {
  padding: 7px 14px;
  background: rgba(192,74,43,0.1); color: #C04A2B;
  border: 1px solid rgba(192,74,43,0.2);
  border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn-danger:hover { background: rgba(192,74,43,0.18); }
.btn-success {
  padding: 7px 14px;
  background: rgba(74,124,66,0.1); color: #2e6b27;
  border: 1px solid rgba(74,124,66,0.2);
  border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn-success:hover { background: rgba(74,124,66,0.18); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 11px; font-weight: 600; color: #8B958F; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  background: #FBF8F1; border: 1px solid #E5DFD3;
  border-radius: 10px;
  font-size: 13px; color: #1C2521;
  outline: none; font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: #1F4D3A; }
.discipline-tree {
  border: 1px solid #E2E8E4;
  border-radius: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  background: #FAFBFA;
}
.tree-subject { margin-bottom: 10px; }
.tree-subject-head {
  font-size: 12px;
  font-weight: 700;
  color: #1F4D3A;
  padding: 6px 8px;
  background: #EEF4F0;
  border-radius: 6px;
  margin-bottom: 4px;
}
.tree-children { display: flex; flex-direction: column; gap: 2px; padding-left: 4px; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  color: #2C3330;
}
.tree-item:hover { border-color: #C5D4CA; background: #F5FAF7; }
.tree-item.selected { border-color: #1F4D3A; background: #E8F2EC; }
.tree-check {
  width: 18px;
  height: 18px;
  border: 1.5px solid #B8C4BE;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.tree-item.selected .tree-check {
  background: #1F4D3A;
  border-color: #1F4D3A;
}
.tree-item-label { flex: 1; line-height: 1.35; }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { margin: 4px 0 0; font-size: 11px; color: #8B958F; line-height: 1.4; }
.discipline-icon-field { display: flex; flex-direction: column; gap: 10px; }
.discipline-icon-preview-wrap {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  border: 1px solid #E5DFD3;
  background: #FBF8F1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.discipline-icon-preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.discipline-icon-placeholder {
  font-size: 11px;
  color: #8B958F;
  text-align: center;
  padding: 8px;
  line-height: 1.3;
}
.discipline-icon-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.discipline-icon-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #E5DFD3;
  background: #FBF8F1;
  vertical-align: middle;
}
.discipline-icon-empty {
  display: inline-flex;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #8B958F;
  background: #F3F0EA;
  border: 1px dashed #D8D2C8;
}

/* Table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #8B958F; border-bottom: 1px solid #E5DFD3;
}
.admin-table td { padding: 12px; border-bottom: 1px solid #F0EDE8; font-size: 13px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #FBF8F1; }
.td-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Status badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 600;
}
.badge-active { background: #E8F4E8; color: #2e6b27; }
.badge-inactive { background: #F0EDE8; color: #8B958F; }
.badge-admin { background: #E8EFEA; color: #1F4D3A; }
.badge-paid { background: #FBEBDB; color: #8B3F12; }
.badge-free { background: #F0EDE8; color: #8B958F; }

/* Inline expand edit */
.assistant-row td { vertical-align: top; }
.prompt-preview {
  font-size: 11px; color: #8B958F;
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: white; border: 1px solid #E5DFD3;
  border-radius: 14px; padding: 18px;
  text-align: center;
}
.stat-num { font-size: 32px; font-weight: 700; color: #1F4D3A; font-family: 'Fraunces', serif; }
.stat-label { font-size: 12px; color: #8B958F; margin-top: 4px; }

/* Toast */
.admin-toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translate(-50%, 80px);
  background: #1C2521; color: white;
  padding: 10px 18px; border-radius: 100px;
  font-size: 13px; z-index: 999;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Edit drawer */
.edit-drawer {
  background: #FBF8F1; border: 1px solid #E5DFD3;
  border-radius: 14px; padding: 20px;
  margin-top: 10px; display: none;
}
.edit-drawer.open { display: block; }
.edit-drawer-actions { display: flex; gap: 10px; margin-top: 16px; }

/* Config active indicator */
.config-active-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.config-active-dot.on { background: #4A7C42; }
.config-active-dot.off { background: #E5DFD3; }

/* 多格式提示词：格式徽章 / 标签 / 来源与预览 */
.fmt-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: #E8EFEA; color: #1F4D3A; font-size: 11px; font-weight: 600;
  vertical-align: middle;
}
.tag-row { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: #F0EDE8; color: #6B7A72; font-size: 11px;
}
.model-input-row { display: flex; gap: 8px; align-items: center; }
.model-input-row .form-input,
.model-input-row .form-select { flex: 1; min-width: 0; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.prompt-source { border: 1px dashed #D9E0DA; border-radius: 10px; padding: 10px; background: #FAFBFA; }
.prompt-source-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.prompt-preview {
  margin-top: 10px; border-top: 1px solid #EEF2EF; padding-top: 10px;
}
.preview-head { font-size: 12px; color: #6B7A72; margin-bottom: 6px; }
.preview-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.meta-chip {
  padding: 2px 8px; border-radius: 6px; background: #EEF4FF; color: #2C3B8E; font-size: 11px;
}
.meta-chip b { font-weight: 600; }
.preview-warn { font-size: 12px; color: #8B3F12; margin-bottom: 6px; }
.preview-body {
  margin: 0; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: #fff; border: 1px solid #EEF2EF; border-radius: 8px; padding: 10px;
  font-size: 12px; line-height: 1.55; color: #2E3A33; font-family: inherit;
}

/* ============ 学习助手编辑器 ============ */
.ae-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 4vh 16px;
}
.ae-overlay.open { display: flex; }
.ae-modal {
  background: white; border-radius: 20px; padding: 26px 28px;
  width: min(860px, 94vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  margin-bottom: 4vh;
}
.ae-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.ae-head h3 { font-family: 'Fraunces', Georgia, serif; margin: 0; font-size: 20px; }
.ae-head-actions { display: flex; align-items: center; gap: 8px; }
.ae-section {
  border: 1px solid #E5DFD3; border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px;
  background: #FDFCF9;
}
.ae-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.ae-section-title { font-size: 13px; font-weight: 700; color: #1F4D3A; }
.ae-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ae-toolbar-label { font-size: 11px; font-weight: 600; color: #8B958F; text-transform: uppercase; }
.ae-fmt-select { padding: 5px 8px; font-size: 12px; }
.ae-actions { display: flex; gap: 10px; margin-top: 4px; }
.ae-icon-row { display: flex; align-items: center; gap: 8px; }
.ae-voice-row { display: flex; align-items: center; gap: 8px; }

/* 基本信息顶行：网格对齐 名称 | URL | 照片框 | 删除 */
.ae-basic-top {
  display: grid;
  grid-template-columns: 200px minmax(140px, 1fr) 72px 36px;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 5px;
  align-items: start;
  margin-bottom: 12px;
}
.ae-basic-top > .form-label:nth-child(1) { grid-column: 1; grid-row: 1; }
.ae-basic-top > .ae-icon-label { grid-column: 2 / 5; grid-row: 1; }
.ae-basic-top > .ae-basic-name-input { grid-column: 1; grid-row: 2; }
.ae-basic-top > .ae-icon-url-col { grid-column: 2; grid-row: 2; min-width: 0; }
.ae-basic-top > .ae-icon-dropzone { grid-column: 3; grid-row: 2; }
.ae-basic-top > .ae-icon-trash { grid-column: 4; grid-row: 2; }
.ae-icon-url-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ae-basic-name-input,
.ae-icon-url-input {
  padding: 9px 12px;
  font-size: 13px;
  min-width: 0;
}
.ae-icon-hint {
  margin: 0;
  font-size: 10px;
  line-height: 1.3;
  color: #8B958F;
}
.ae-icon-dropzone {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1.5px dashed #C5CEC8;
  background: linear-gradient(160deg, #FBF8F1 0%, #F0EBE1 100%);
  cursor: pointer;
  overflow: hidden;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.ae-icon-dropzone:hover {
  border-color: #1F4D3A;
  box-shadow: 0 2px 10px rgba(31, 77, 58, 0.1);
}
.ae-icon-dropzone:focus-visible {
  border-color: #1F4D3A;
  box-shadow: 0 0 0 3px rgba(31, 77, 58, 0.15);
}
.ae-icon-dropzone.dragover {
  border-color: #1F4D3A;
  border-style: solid;
  background: #E8F2EC;
  box-shadow: 0 0 0 3px rgba(31, 77, 58, 0.12);
}
.ae-icon-dropzone.has-image {
  border-style: solid;
  border-color: #D8D2C8;
  background: #fff;
}
.ae-icon-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ae-icon-dropzone-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}
.ae-icon-dropzone-plus {
  font-size: 20px;
  font-weight: 300;
  color: #A8B5AE;
  line-height: 1;
}
.ae-icon-dropzone-text {
  font-size: 9px;
  font-weight: 600;
  color: #9AA8A1;
  text-align: center;
  line-height: 1.2;
}
.ae-icon-dropzone-mask,
.ae-icon-dropzone-hover {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}
.ae-icon-dropzone-mask {
  background: rgba(31, 77, 58, 0.82);
  color: #fff;
}
.ae-icon-dropzone.dragover .ae-icon-dropzone-mask { display: flex; }
.ae-icon-dropzone.has-image:hover .ae-icon-dropzone-hover {
  display: flex;
  background: rgba(28, 37, 33, 0.52);
  color: #fff;
}
.ae-icon-dropzone.pending-upload::after {
  content: "待上传";
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(31, 77, 58, 0.9);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
}
.ae-icon-trash {
  width: 36px;
  height: 72px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #E5DFD3;
  border-radius: 10px;
  background: #fff;
  color: #8B958F;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ae-icon-trash:hover:not(:disabled) {
  color: #B9433A;
  border-color: rgba(185, 67, 58, 0.35);
  background: rgba(185, 67, 58, 0.06);
}
.ae-icon-trash:disabled {
  opacity: 0.35;
  cursor: default;
}
.ae-basic-grid {
  gap: 12px 16px;
}
@media (max-width: 720px) {
  .ae-basic-top {
    grid-template-columns: 1fr 72px 36px;
    grid-template-rows: auto auto auto auto;
  }
  .ae-basic-top > .form-label:nth-child(1) { grid-column: 1 / -1; grid-row: 1; }
  .ae-basic-top > .ae-icon-label { grid-column: 1 / -1; grid-row: 2; }
  .ae-basic-top > .ae-basic-name-input { grid-column: 1 / -1; grid-row: 3; }
  .ae-basic-top > .ae-icon-url-col { grid-column: 1; grid-row: 4; }
  .ae-basic-top > .ae-icon-dropzone { grid-column: 2; grid-row: 4; }
  .ae-basic-top > .ae-icon-trash { grid-column: 3; grid-row: 4; height: 72px; }
}

/* 图标正方形裁剪弹窗 */
.ae-crop-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.ae-crop-overlay.open { display: flex; }
.ae-crop-modal {
  background: #fff; border-radius: 16px; padding: 20px 22px;
  width: min(380px, 96vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.ae-crop-head { margin-bottom: 14px; }
.ae-crop-head h4 {
  margin: 0 0 4px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px; color: #1F4D3A;
}
.ae-crop-head .form-hint { margin: 0; }
.ae-crop-stage-wrap {
  position: relative;
  width: 320px; height: 320px;
  margin: 0 auto 12px;
  border-radius: 12px;
  overflow: hidden;
  background: #2a2f2c;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.ae-crop-stage-wrap.dragging { cursor: grabbing; }
.ae-crop-canvas {
  display: block;
  width: 320px; height: 320px;
}
.ae-crop-frame {
  position: absolute;
  inset: 20px;
  border: 2px solid #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.ae-crop-zoom-label {
  display: block;
  font-size: 11px; font-weight: 600;
  color: #8B958F;
  letter-spacing: 0.04em; margin-bottom: 6px;
}
.ae-crop-zoom {
  width: 100%; margin-bottom: 16px;
  accent-color: #1F4D3A;
}
.ae-crop-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Chip 多选（学科 / 年级） */
.chip-select {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 10px; border: 1px solid #E5DFD3; border-radius: 10px;
  background: #FBF8F1;
}
.chip-opt {
  padding: 5px 12px; border-radius: 100px;
  border: 1px solid #E5DFD3; background: white;
  font-size: 12.5px; color: #4A5853; cursor: pointer;
  font-family: inherit; transition: all 0.12s;
  display: inline-flex; align-items: center; gap: 5px;
}
.chip-opt:hover { border-color: #1F4D3A; color: #1F4D3A; }
.chip-opt.selected {
  background: #1F4D3A; border-color: #1F4D3A; color: white; font-weight: 600;
}
.chip-opt.chip-add {
  border-style: dashed; color: #6B7A72; background: transparent;
}
.chip-opt.chip-add:hover { border-color: #1F4D3A; color: #1F4D3A; }

/* 学科 chip：主体（关联开关）+ ✕（删除学科） */
.chip-wrap { display: inline-flex; align-items: stretch; }
.chip-wrap .chip-opt { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chip-del {
  border: 1px solid #E5DFD3; border-left: none;
  border-top-right-radius: 100px; border-bottom-right-radius: 100px;
  background: white; color: #B9433A; cursor: pointer;
  font-size: 11px; line-height: 1; padding: 0 9px; font-family: inherit;
  transition: all 0.12s;
}
.chip-del:hover { background: #B9433A; color: white; border-color: #B9433A; }
.chip-wrap.selected .chip-del { border-color: #1F4D3A; }

/* 颜色选择器 + 文本输入 */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-swatch {
  width: 38px; height: 38px; padding: 0; flex-shrink: 0;
  border: 1px solid #E5DFD3; border-radius: 10px;
  background: #FBF8F1; cursor: pointer;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 4px; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 6px; }
#aeColorHint.warn { color: #8B3F12; }
.ae-icon-preview {
  width: 34px; height: 34px; border-radius: 8px; object-fit: cover;
  border: 1px solid #E5DFD3; background: #FBF8F1; flex-shrink: 0;
}
.ae-visual-placeholder {
  border: 1.5px dashed #D8D2C8; border-radius: 12px;
  padding: 18px; text-align: center;
  font-size: 13px; color: #8B958F; background: #FBF8F1;
  line-height: 1.7;
}
.ae-visual-placeholder span { font-size: 11px; color: #ABB4AE; }

/* 简易代码编辑器：高亮层 + 透明文字 textarea 叠加 */
.code-editor {
  position: relative;
  border: 1px solid #E5DFD3; border-radius: 12px;
  background: #FFFFFF; overflow: hidden;
  height: 300px;
}
.code-editor:focus-within { border-color: #1F4D3A; }
.code-editor-pre, .code-editor-input {
  margin: 0; border: 0; width: 100%; height: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.6;
  padding: 12px 14px;
  white-space: pre-wrap; word-break: break-word;
  tab-size: 2;
}
.code-editor-pre {
  position: absolute; inset: 0;
  overflow: hidden;
  color: #2E3A33;
  pointer-events: none;
}
.code-editor-input {
  position: relative;
  background: transparent;
  color: transparent;
  caret-color: #1C2521;
  resize: none; outline: none;
  overflow: auto;
  display: block;
}
.code-editor-input::placeholder { color: #ABB4AE; }
.code-editor.dragover { border-color: #1F4D3A; }
.code-editor-drop {
  position: absolute; inset: 0; z-index: 3;
  display: none; align-items: center; justify-content: center;
  background: rgba(31,77,58,0.88); color: white;
  font-size: 14px; font-weight: 600; border-radius: 12px;
  pointer-events: none;
}
.code-editor.dragover .code-editor-drop { display: flex; }

/* 高亮 token */
.tok-key { color: #0E6E8C; }
.tok-str { color: #2E7D32; }
.tok-num { color: #B26A00; }
.tok-bool { color: #7B3FA0; font-weight: 600; }
.tok-punc { color: #9AA39D; }
.tok-comment { color: #9AA39D; font-style: italic; }
.tok-head { color: #1F4D3A; font-weight: 700; }
.tok-md-mark { color: #B26A00; }
.tok-code { color: #8B3F12; background: #FBF3E8; border-radius: 3px; }

/* API 配置分组 */
.cfg-group-title {
  font-size: 13px; font-weight: 700; color: #1F4D3A;
  padding: 8px 0; border-bottom: 2px solid #E8EFEA; margin-bottom: 4px;
}
.cfg-default-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 100px;
  background: #E8F4E8; color: #2e6b27; font-size: 11px; font-weight: 700;
}

/* ============ 板书样式编辑器（母版式拖拽） ============ */
.bs-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.bs-list-pane { min-height: 200px; }
.bs-list { display: flex; flex-direction: column; gap: 8px; }
.bs-list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px;
  cursor: pointer; transition: all .12s; background: #fff;
}
.bs-list-item:hover { border-color: #1F4D3A; background: #f6faf7; }
.bs-list-item.active { border-color: #1F4D3A; background: #eaf3ed; box-shadow: 0 0 0 2px rgba(31,77,58,.12); }
.bs-list-item .bs-li-name { font-weight: 600; font-size: 13px; color: #1C2521; }
.bs-list-item .bs-li-meta { font-size: 11px; color: #8a948e; }
.bs-list-empty { font-size: 13px; color: #8a948e; padding: 12px 4px; }

.bs-editor-pane { display: flex; flex-direction: column; gap: 12px; }
.bs-editor-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bs-editor-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.bs-stage-wrap { width: 100%; }
.bs-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #FCFDFB;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, rgba(31,77,58,.06) 31px, rgba(31,77,58,.06) 32px);
  border: 1px solid #d8ddd9; border-radius: 12px; overflow: hidden;
  user-select: none; touch-action: none;
}
.bs-region {
  position: absolute; box-sizing: border-box;
  border: 1.5px solid rgba(31,77,58,.5); border-radius: 8px;
  background: rgba(31,77,58,.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #1F4D3A; cursor: move; overflow: hidden;
}
.bs-region.selected { border-color: #B26A00; box-shadow: 0 0 0 2px rgba(178,106,0,.25); z-index: 2; }
.bs-region-tag {
  position: absolute; top: 4px; left: 6px; font-size: 10px; font-weight: 700;
  color: #1F4D3A; background: rgba(255,255,255,.8); padding: 1px 6px; border-radius: 100px;
  pointer-events: none;
}
.bs-region-body { padding: 6px 8px; text-align: center; pointer-events: none; max-width: 100%; }
.bs-region-handle {
  position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px;
  background: #B26A00; border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; z-index: 3;
}
.bs-region[data-type="geometry"] { background: rgba(14,110,140,.08); border-color: rgba(14,110,140,.55); color: #0E6E8C; }
.bs-region[data-type="geometry"] .bs-region-tag { color: #0E6E8C; }
.bs-region[data-type="mermaid"] { background: rgba(123,63,160,.08); border-color: rgba(123,63,160,.5); color: #7B3FA0; }
.bs-region[data-type="mermaid"] .bs-region-tag { color: #7B3FA0; }
.bs-region[data-type="label"] { background: rgba(178,106,0,.06); border-color: rgba(178,106,0,.45); }

.bs-props { border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.bs-props-row { display: flex; align-items: center; gap: 12px; }
.bs-props-type { font-weight: 700; color: #1F4D3A; }
.bs-props-pos { font-size: 12px; color: #8a948e; }
.bs-mini { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #475247; }
.bs-mini input[type="number"], .bs-mini select { padding: 4px 6px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 12px; }
.bs-mini input[type="color"] { width: 32px; height: 26px; padding: 1px; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; }
