/* ============ 管理后台组件样式（Layout 见 admin-shell.css，Token 见 tokens.css） ============ */

/* Cards */
.admin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.admin-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0;
}
.admin-card-title { font-weight: 600; font-size: 15px; }
/* 列表工具栏：统计在上 → 左筛选 / 右新增 */
.admin-card-head + .admin-list-stats { margin-top: 14px; }
.admin-card-head + .admin-list-toolbar { margin-top: 14px; }
.admin-list-stats + .admin-list-toolbar { margin-top: 10px; }
.admin-list-stats,
.usage-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 4px;
}
.admin-list-stats:empty,
.usage-summary:empty { display: none; margin: 0; }
.admin-list-stats:not(.usage-summary--side) span,
.usage-summary:not(.usage-summary--side) span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-brand-subtle);
  color: var(--color-brand);
  border: 1px solid var(--border-default);
}
.usage-summary--side {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  justify-content: flex-end;
  align-content: flex-end;
  gap: 7px;
  margin: 0;
}
.usage-stat {
  min-width: 0;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-default);
}
.usage-stat:first-child {
  background: var(--color-brand-subtle);
  border-color: var(--border-default);
}
.usage-stat-value {
  display: block;
  color: var(--color-brand);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}
.usage-stat-label {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
}
.usage-stat--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}
.admin-list-toolbar {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.admin-list-toolbar--compact {
  margin-top: 8px;
  margin-bottom: 12px;
}
.admin-list-toolbar__filters {
  flex: 1;
  min-width: 0;
}
.admin-list-toolbar__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-self: flex-end;
}
.admin-list-toolbar__actions--stats {
  max-width: min(560px, 52%);
  align-self: stretch;
  align-items: flex-end;
}

/* 筛选区：JS 分成 1～2 行，搜索钮贴在末行末尾 */
.list-filters {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
}
.list-filters__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  max-width: 100%;
  width: 100%;
}
.list-filters__row .usage-filter-group {
  flex: 0 0 auto;
  min-width: 132px;
  max-width: 190px;
}
.list-filters__row .usage-search-group {
  flex: 0 1 auto;
  min-width: 220px;
  max-width: 300px;
}
.list-filters__row .usage-search {
  min-width: 220px;
  max-width: 300px;
  width: 100%;
}
.list-filters__row .btn-list--search,
.list-filters__row .usage-search-btn {
  flex: 0 0 auto;
  align-self: flex-end;
}

/* 列表工具栏按钮（36px，与下拉框同高） */
.btn-list {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height-md);
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-sizing: border-box;
  line-height: 1;
  transition: background var(--transition-base), border-color var(--transition-base), color var(--transition-base);
}
.btn-list:focus-visible {
  box-shadow: var(--focus-ring);
}
.btn-list--search {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-list--search:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-subtle);
}
.btn-list--add {
  background: var(--color-brand);
  color: var(--text-on-brand);
  border-color: var(--color-brand);
}
.btn-list--add:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}
.btn-list--ai {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-list--ai:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}
.btn-list--apply {
  background: var(--color-brand);
  color: var(--text-on-brand);
  border-color: var(--color-brand);
}
.btn-list--apply:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}
/* 兼容旧 btn-add 类名 */
.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-sizing: border-box;
}
.btn-add--primary { background: var(--color-brand); color: var(--text-on-brand); border-color: var(--color-brand); }
.btn-add--secondary { background: var(--bg-page-warm); color: #5C4A1F; border-color: var(--border-default); }
.btn-add--sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 10px; }

/* Tab panels（子导航样式见 admin-shell.css） */
.admin-tab-panel,
.billing-panel { display: none; }
.admin-tab-panel.active,
.billing-panel.active { display: block; }

.studio-review-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  border-bottom: 1px solid var(--border-default);
}
.studio-review-tab {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
}
.studio-review-tab.active {
  border-bottom-color: var(--color-brand);
  color: var(--color-brand);
}
.studio-review-tab span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  font-size: 12px;
}
.studio-submissions-table td:last-child {
  white-space: nowrap;
}
.studio-submission-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.studio-submission-status--pending {
  border-color: var(--status-info-border);
  background: var(--status-info-bg);
  color: var(--status-info-text);
}
.studio-submission-status--approved {
  border-color: var(--status-success-border);
  background: var(--status-success-bg);
  color: var(--status-success-text);
}
.studio-submission-status--rejected {
  border-color: var(--status-danger-border);
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}
.studio-review-detail-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.studio-review-detail-content {
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #f7f8fa;
  white-space: pre-wrap;
}
.admin-list-toolbar--compact .usage-search-group {
  min-width: 100%;
  max-width: none;
}
.billing-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-page-warm);
}
.billing-check-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #2C3E35;
  cursor: pointer;
}
.billing-scope-mode {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  font-size: 13px;
}
.billing-scope-mode label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* Billing modals */
.billing-overlay .billing-modal {
  width: min(580px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.billing-overlay .billing-modal.admin-detail-modal--xwide {
  width: min(1120px, 96vw);
  max-height: 94vh;
}
.billing-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.billing-modal-head h3 {
  font-family: 'Fraunces', Georgia, serif;
  margin: 0;
  font-size: 18px;
  color: var(--color-brand);
}
.billing-modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  font-size: 18px;
  line-height: 1;
  color: #6B7A72;
  cursor: pointer;
  flex-shrink: 0;
}
.billing-modal-close:hover { border-color: var(--color-brand); color: var(--color-brand); }
.billing-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}
.billing-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-inset);
}
.billing-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.billing-form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .billing-form-row-2 { grid-template-columns: 1fr; }
}
.billing-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.billing-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.billing-field .form-input { width: 100%; box-sizing: border-box; }
.billing-field-readonly .form-input {
  background: var(--bg-surface-subtle);
  color: #6B7A72;
  cursor: default;
}
.billing-field-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #2C3E35;
  cursor: pointer;
}
.billing-section {
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--bg-inset);
}
.billing-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-brand);
  margin-bottom: 10px;
}
.billing-entitlement-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}
.billing-rate-card {
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg-surface);
}
.billing-rate-card:last-child { margin-bottom: 0; }
.billing-rate-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-brand);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.billing-rate-unit {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* User credits page */
.credits-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.credits-stat-card {
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg-inset);
}
.credits-stat-card--wide { grid-column: 1 / -1; }
.credits-stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.credits-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-brand);
  word-break: break-word;
}
.credits-chip {
  display: inline-block;
  padding: 3px 10px;
  margin: 0 6px 4px 0;
  border-radius: 999px;
  background: var(--border-subtle);
  color: var(--color-brand);
  font-size: 12px;
  font-weight: 600;
}
.credits-lock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #F0C9A8;
  border-left: 4px solid #C05A21;
  border-radius: 10px;
  background: var(--status-warning-bg);
  color: #8B3F12;
  font-size: 13px;
  font-weight: 600;
}
.credits-manage-form {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  margin-top: 4px;
}
.credits-manage-section {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 18px;
  margin-bottom: 18px;
}
.credits-manage-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.credits-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.credits-actions-spacer { flex: 1 1 auto; }
.credits-quota-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.credits-quota-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 1px;
}
.credits-quota-amount { min-width: 0; }
@media (max-width: 640px) {
  .credits-quota-row { grid-template-columns: 1fr; }
  .credits-detail-grid { grid-template-columns: repeat(2, 1fr); }
  .credits-actions-row { flex-direction: column; align-items: stretch; }
  .credits-actions-spacer { display: none; }
}
.credits-subject-block { margin-top: 14px; }
.credits-subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px 12px;
  margin-top: 6px;
}
.credits-subject-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-inset);
  font-size: 12px;
  color: #2C3E35;
  cursor: pointer;
}
.credits-subject-grid input { accent-color: var(--color-brand); }
.credits-subjects-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Generic confirm / prompt dialog (replaces native window.confirm and window.prompt) */
.confirm-overlay {
  position: fixed; inset: 0; z-index: var(--z-confirm);
  background: rgba(16, 24, 40, 0.4);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.confirm-overlay.open { display: flex; }
.confirm-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: min(420px, 92vw);
  box-shadow: var(--shadow-overlay);
}
.confirm-modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}
.confirm-modal-message {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  color: var(--text-secondary);
  white-space: pre-line;
}
.confirm-modal-input-wrap { margin-top: 14px; }
.confirm-modal-input-wrap .form-label { display: block; margin-bottom: var(--space-2); }
.confirm-modal-textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  line-height: var(--line-height-relaxed);
}
.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-md);
  padding: 0 var(--space-4);
  background: var(--color-brand);
  color: var(--text-on-brand);
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-base), border-color var(--transition-base);
}
.btn-primary:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}
.btn-primary:focus-visible {
  box-shadow: var(--focus-ring);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-md);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition-base), color var(--transition-base), background var(--transition-base);
}
.btn-secondary:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-surface-subtle);
}
.btn-secondary:focus-visible {
  box-shadow: var(--focus-ring);
}
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-sm);
  padding: 0 var(--space-3);
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-family: inherit;
}
.btn-danger:hover {
  background: var(--status-danger-bg);
}
.btn-danger:focus-visible {
  box-shadow: var(--focus-ring);
}
.btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-sm);
  padding: 0 var(--space-3);
  background: var(--status-success-bg);
  color: var(--status-success-text);
  border: 1px solid var(--status-success-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-family: inherit;
}
.btn-success:hover {
  background: #D1FADF;
}
.btn-success:focus-visible {
  box-shadow: var(--focus-ring);
}

/* 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; }
.admin-password-reset-button {
  width: 100%;
}
.form-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.form-input, .form-select, .form-textarea {
  padding: 0 var(--space-3);
  min-height: var(--control-height-md);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.form-textarea {
  min-height: 80px;
  padding: var(--space-2) var(--space-3);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(132, 173, 255, 0.25);
}
.form-input:disabled, .form-select:disabled, .form-textarea:disabled {
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}
.discipline-tree {
  border: 1px solid #E2E8E4;
  border-radius: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-surface-subtle);
}
.tree-subject { margin-bottom: 10px; }
.tree-subject-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-brand);
  padding: 6px 8px;
  background: var(--color-brand-subtle);
  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: var(--bg-surface);
  cursor: pointer;
  font-size: 12px;
  color: #2C3330;
}
.tree-item:hover { border-color: var(--border-strong); background: var(--bg-surface-subtle); }
.tree-item.selected { border-color: var(--color-brand); background: var(--color-brand-subtle); }
.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: var(--color-brand);
  border-color: var(--color-brand);
}
.tree-item-label { flex: 1; line-height: 1.35; }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { margin: var(--space-1) 0 0; font-size: var(--font-size-xs); color: var(--text-muted); line-height: var(--line-height-relaxed); }
.discipline-icon-field { display: flex; flex-direction: column; gap: 10px; }
.discipline-icon-preview-wrap {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  border: 1px solid var(--border-default);
  background: var(--bg-page-warm);
  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: var(--text-muted);
  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 var(--border-default);
  background: var(--bg-page-warm);
  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: var(--text-muted);
  background: #F3F0EA;
  border: 1px dashed #D8D2C8;
}

/* Table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface-subtle);
  white-space: nowrap;
}
.admin-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-size-sm);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--bg-surface-hover); }
.admin-table tbody tr:focus-within td { background: var(--bg-surface-hover); }
#assistantsTable .assistants-actions-col {
  width: 360px;
  min-width: 360px;
}
#assistantsTable td.assistants-actions-col {
  white-space: nowrap;
}
#assistantsTable td.assistants-actions-col > .td-actions {
  display: flex;
  flex-flow: row nowrap;
  width: max-content;
}
.td-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.td-actions .permission-group-action {
  width: 52px;
}
.admin-table .permission-groups-type {
  width: 150px;
  white-space: nowrap;
}
.admin-table .permission-groups-admin-count {
  text-align: center;
}
.admin-table th.cell-number,
.admin-table td.cell-number {
  text-align: right;
}
#page-subjects .admin-table {
  table-layout: fixed;
}
#page-subjects .admin-table th:nth-child(1),
#page-subjects .admin-table td:nth-child(1) {
  width: 34%;
}
#page-subjects .admin-table th:nth-child(2),
#page-subjects .admin-table td:nth-child(2) {
  width: 22%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#page-subjects .admin-table th:nth-child(3),
#page-subjects .admin-table td:nth-child(3) {
  width: 14%;
}
#page-subjects .admin-table th:nth-child(4),
#page-subjects .admin-table td:nth-child(4) {
  width: 30%;
}
.permission-matrix-table th.cell-number,
.permission-matrix-table td.cell-number {
  text-align: center;
}
.permission-overrides-table th:not(:first-child),
.permission-overrides-table td:not(:first-child) {
  text-align: center;
}
/* 表格行内操作按钮（32px，按功能配色） */
.td-actions .btn-secondary,
.td-actions .btn-row-edit,
.admin-table tbody td > .btn-secondary,
.usage-cell-middle .btn-secondary,
.usage-pagination .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  cursor: pointer;
  font-family: inherit;
  box-sizing: border-box;
  line-height: 1;
  transition: border-color var(--transition-base), background var(--transition-base), color var(--transition-base);
}
.td-actions .btn-secondary:hover,
.td-actions .btn-row-edit:hover,
.admin-table tbody td > .btn-secondary:hover,
.usage-cell-middle .btn-secondary:hover,
.usage-pagination .btn-secondary:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-surface-subtle);
}
.td-actions .btn-success,
.td-actions .btn-row-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: #E8F4E8;
  color: #2e6b27;
  border: 1px solid #B8D4B4;
  cursor: pointer;
  font-family: inherit;
  box-sizing: border-box;
  line-height: 1;
}
.td-actions .btn-success:hover,
.td-actions .btn-row-success:hover {
  background: #D4EBD4;
  border-color: #2e6b27;
}
.td-actions .btn-danger,
.td-actions .btn-row-danger,
.admin-table tbody td > .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: #FDF0EC;
  color: #C04A2B;
  border: 1px solid #E8C4B8;
  cursor: pointer;
  font-family: inherit;
  box-sizing: border-box;
  line-height: 1;
}
.td-actions .btn-danger:hover,
.td-actions .btn-row-danger:hover,
.admin-table tbody td > .btn-danger:hover {
  background: #F9E2DA;
  border-color: #C04A2B;
}
.usage-pagination .btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Status badges — 语义色全站统一 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.35;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-success,
.badge-active { background: var(--status-success-bg); color: var(--status-success-text); border-color: var(--status-success-border); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning-text); border-color: var(--status-warning-border); }
.badge-danger { background: var(--status-danger-bg); color: var(--status-danger-text); border-color: var(--status-danger-border); }
.badge-info { background: var(--status-info-bg); color: var(--status-info-text); border-color: var(--status-info-border); }
.badge-neutral,
.badge-inactive { background: var(--status-neutral-bg); color: var(--status-neutral-text); border-color: var(--status-neutral-border); }
.badge-admin { background: var(--color-brand-subtle); color: var(--color-brand); border-color: #C5D9CE; }
.badge-paid { background: var(--status-warning-bg); color: var(--status-warning-text); border-color: var(--status-warning-border); }
.badge-free { background: var(--status-neutral-bg); color: var(--status-neutral-text); border-color: var(--status-neutral-border); }

.fmt-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-xs);
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  background: var(--status-neutral-bg);
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  vertical-align: middle;
  margin-left: var(--space-1);
}

.tag-chip {
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  border: 1px solid var(--border-default);
}

/* 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;
}

/* Dashboard 行（stat 卡片见 admin-shell.css .admin-dashboard） */
.dash-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.dash-row:last-child { border-bottom: 0; }
.dash-row span { color: var(--text-secondary); font-size: var(--font-size-sm); }
.dash-row strong {
  color: var(--text-primary); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold);
  text-align: right; word-break: break-word;
}
/* Admin list filters — toolbar 内由 list-filters 承载 */
.usage-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}
.list-filters.usage-filters {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  margin-left: 0;
}
.usage-filter-group {
  display: grid;
  gap: 4px;
  min-width: 128px;
}
.usage-filter-group label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  letter-spacing: 0.03em;
}
.usage-filter-group .form-select {
  min-width: 128px;
  height: var(--control-height-md);
}
.usage-search-group {
  min-width: 230px;
  max-width: 280px;
}
.usage-search-wrap {
  position: relative;
}
.usage-search {
  height: var(--control-height-md);
  min-width: 230px;
  max-width: 280px;
  width: 100%;
  padding-right: 28px;
  box-sizing: border-box;
}
.usage-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  line-height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: 50%;
}
.usage-search-clear:hover {
  background: #E9ECE9;
  color: #2C3E35;
}
.usage-search-btn,
.btn-list--search {
  height: 36px;
  align-self: end;
  padding: 0 14px;
}
.usage-table th,
.usage-table td {
  vertical-align: top;
}
.usage-table td.usage-cell-middle {
  vertical-align: middle;
}
.usage-table th:nth-child(1),
.usage-table td:nth-child(1) {
  width: 170px;
  max-width: 170px;
}
.usage-table td:nth-child(1) strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usage-table th:nth-child(2) { min-width: 190px; }
.usage-table th:nth-child(3) { min-width: 170px; }
.usage-table th:nth-child(5),
.usage-table td:nth-child(5) {
  min-width: 112px;
  max-width: 128px;
}
.usage-table th:nth-child(6),
.usage-table th:nth-child(7) {
  white-space: nowrap;
}
.usage-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}
.usage-pagination button {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
}
.usage-pagination span {
  font-size: 12px;
  color: var(--text-muted);
}
.usage-muted {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
  word-break: break-word;
}
.usage-section {
  margin-top: 20px;
}
.usage-empty {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--bg-page-warm);
  color: var(--text-muted);
}
.usage-message {
  margin-top: 10px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--bg-page-warm);
  padding: 12px;
}
.usage-message.assistant { background: var(--bg-surface-subtle); }
.usage-message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #6B7A72;
  font-size: 12px;
}
.usage-message-head span {
  color: var(--text-muted);
}
.usage-message pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  color: #1C2521;
  line-height: 1.55;
}
.feedback-content {
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--bg-page-warm);
  padding: 14px;
  color: #1C2521;
}
@media (max-width: 820px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .admin-list-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .list-filters {
    width: 100%;
  }
  .admin-list-toolbar__actions {
    width: 100%;
    justify-content: flex-end;
  }
  .admin-list-toolbar__actions--stats {
    max-width: none;
    align-self: auto;
  }
  .usage-summary--side {
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .list-filters__row {
    width: 100%;
  }
  .list-filters__row .usage-filter-group,
  .list-filters__row .usage-search-group {
    min-width: calc(50% - 6px);
    flex: 1 1 calc(50% - 6px);
    max-width: none;
  }
  .list-filters__row .usage-search,
  .list-filters__row .usage-search-group {
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }
  .usage-summary--side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .usage-stat:last-child {
    grid-column: 1 / -1;
  }
}

/* Toast */
.admin-toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--text-primary);
  color: var(--text-on-brand);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  z-index: var(--z-toast);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Edit drawer — 见 admin-shell.css */

/* 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: var(--border-default); }

/* 多格式提示词：来源与预览 */
.tag-row { margin-top: var(--space-1); display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* AI Tutors 列表 */
.cell-primary__body--assistant { max-width: 220px; }
.tag-chip-more { color: var(--text-muted); cursor: default; }
.btn-xs { padding: 4px 10px; font-size: var(--font-size-sm); }
.prompt-source { border: 1px dashed #D9E0DA; border-radius: 10px; padding: 10px; background: var(--bg-surface-subtle); }
.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 var(--border-subtle); 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: var(--bg-surface); border: 1px solid var(--border-subtle); 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: var(--bg-surface); border-radius: 20px; padding: 26px 28px;
  width: min(920px, 96vw);
  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 var(--border-default); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px;
  background: var(--bg-inset);
}
.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: var(--color-brand); }
.ae-model-details { border: 1px solid var(--line); border-radius: 8px; padding: 0; }
.ae-model-details > summary { cursor: pointer; padding: 11px 12px; font-size: 13px; font-weight: 600; }
.ae-model-details__body { padding: 0 12px 12px; }
.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; }
.ae-prompt-binding {
  display:grid;grid-template-columns:150px minmax(0,1fr);gap:14px;align-items:start;
  padding:12px 0;border-top:1px solid var(--border-subtle);
}
.ae-prompt-binding:first-of-type { border-top:0;padding-top:0; }
.ae-prompt-binding__label { padding-top:9px;font-size:13px;font-weight:650;color:var(--text-primary); }
.ae-prompt-binding__control { min-width:0; }
.ae-prompt-current-card {
  display:flex;align-items:center;justify-content:space-between;gap:14px;min-height:58px;
  padding:10px 12px;border:1px solid var(--border-default);border-radius:10px;background:var(--bg-surface);
}
.ae-prompt-current-card__body { min-width:0; }
.ae-prompt-current-card__name { font-size:13px;font-weight:650;color:var(--text-primary); }
.ae-prompt-current-card__meta { margin-top:3px;font-size:11px;color:var(--text-muted); }
.ae-prompt-editor-overlay { z-index:460; }
.ae-prompt-manager-modal { width:min(1040px,96vw); }
.ae-prompt-manager-tabs { display:flex;gap:6px;border-bottom:1px solid var(--border-default);margin-bottom:14px; }
.ae-prompt-manager-tab {
  border:0;border-bottom:2px solid transparent;background:transparent;padding:9px 12px;
  color:var(--text-secondary);font-size:13px;font-weight:650;cursor:pointer;
}
.ae-prompt-manager-tab.active { color:var(--color-brand);border-bottom-color:var(--color-brand); }
.ae-prompt-manager-layout { display:grid;grid-template-columns:280px minmax(0,1fr);gap:14px;min-height:520px; }
.ae-prompt-manager-sidebar,.ae-prompt-manager-main {
  border:1px solid var(--border-default);border-radius:12px;background:var(--bg-surface);padding:12px;
}
.ae-prompt-manager-sidebar__head { display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px;font-size:12px;font-weight:700; }
.ae-prompt-manager-list { display:flex;flex-direction:column;gap:7px;max-height:455px;overflow:auto; }
.ae-prompt-manager-version {
  width:100%;border:1px solid var(--border-subtle);border-radius:9px;background:var(--bg-surface);padding:10px;
  text-align:left;color:var(--text-primary);cursor:pointer;
}
.ae-prompt-manager-version:hover,.ae-prompt-manager-version.selected { border-color:var(--color-brand); }
.ae-prompt-manager-version.selected { background:var(--color-brand-subtle); }
.ae-prompt-manager-version__top { display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:650; }
.ae-prompt-manager-version__meta { margin-top:5px;font-size:10px;color:var(--text-muted); }
.ae-prompt-manager-detail-head { display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px; }
.ae-prompt-manager-detail-title { margin:0;font-size:17px;color:var(--text-primary); }
.ae-prompt-manager-detail-meta { margin-top:5px;font-size:11px;color:var(--text-muted); }
.ae-prompt-manager-preview {
  margin:0;min-height:360px;max-height:420px;overflow:auto;white-space:pre-wrap;word-break:break-word;
  padding:14px;border:1px solid var(--border-subtle);border-radius:10px;background:var(--bg-surface-subtle);
  color:var(--text-primary);font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
}
.ae-prompt-manager-empty { display:grid;place-items:center;min-height:420px;text-align:center;color:var(--text-muted);font-size:13px; }
.ae-prompt-editor-content { min-height:360px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.55; }
@media (max-width: 760px) {
  .ae-prompt-binding { grid-template-columns:1fr;gap:6px; }
  .ae-prompt-binding__label { padding-top:0; }
  .ae-prompt-manager-layout { grid-template-columns:1fr; }
  .ae-prompt-manager-sidebar { max-height:240px; }
}

/* 基本信息顶行：网格对齐 Name | 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: var(--text-muted);
}
.ae-icon-dropzone {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1.5px dashed #C5CEC8;
  background: linear-gradient(160deg, var(--bg-page-warm) 0%, #E3DFD8 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: var(--color-brand);
  box-shadow: 0 2px 10px rgba(31, 77, 58, 0.1);
}
.ae-icon-dropzone:focus-visible {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(31, 77, 58, 0.15);
}
.ae-icon-dropzone.dragover {
  border-color: var(--color-brand);
  border-style: solid;
  background: var(--color-brand-subtle);
  box-shadow: 0 0 0 3px rgba(31, 77, 58, 0.12);
}
.ae-icon-dropzone.has-image {
  border-style: solid;
  border-color: #D8D2C8;
  background: var(--bg-surface);
}
.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;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.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: var(--text-on-brand);
}
.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: var(--text-on-brand);
}
.ae-icon-trash {
  width: 36px;
  height: 72px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
  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;
}
.ae-default-option {
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
}
.ae-default-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #2E3A33;
  margin: 0;
}
.ae-default-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--color-brand);
}
@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: var(--bg-surface); 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: var(--color-brand);
}
.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 var(--bg-surface);
  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: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 6px;
}
.ae-crop-zoom {
  width: 100%; margin-bottom: 16px;
  accent-color: var(--color-brand);
}
.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 var(--border-default); border-radius: 10px;
  background: var(--bg-page-warm);
}
.chip-opt {
  padding: 5px 12px; border-radius: 100px;
  border: 1px solid var(--border-default); background: var(--bg-surface);
  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: var(--color-brand); color: var(--color-brand); }
.chip-opt.selected {
  background: var(--color-brand); border-color: var(--color-brand); color: white; font-weight: 600;
}
.chip-opt.chip-add {
  border-style: dashed; color: #6B7A72; background: transparent;
}
.chip-opt.chip-add:hover { border-color: var(--color-brand); color: var(--color-brand); }

.chip-wrap { display: inline-flex; align-items: stretch; }
.chip-wrap .chip-opt { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chip-del {
  padding: 5px 8px; border: 1px solid var(--border-default); border-left: none;
  border-radius: 0 100px 100px 0; background: var(--bg-page-warm);
  font-size: 11px; color: #8B958F; cursor: pointer; font-family: inherit;
}
.chip-del:hover { background: #B9433A; color: white; border-color: #B9433A; }
.chip-wrap.selected .chip-del { border-color: var(--color-brand); }

/* 颜色选择器 + 文本输入 */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-swatch {
  width: 38px; height: 38px; padding: 0; flex-shrink: 0;
  border: 1px solid var(--border-default); border-radius: 10px;
  background: var(--bg-page-warm); cursor: pointer;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 4px; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 6px; }
#aeColorHint.warn { color: #8B3F12; }
#aeDescHint.warn { color: #8B3F12; }
.ae-icon-preview {
  width: 34px; height: 34px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border-default); background: var(--bg-page-warm); 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: var(--bg-page-warm);
  line-height: 1.7;
}
.ae-visual-placeholder span { font-size: 11px; color: #ABB4AE; }

/* 简易代码编辑器：高亮层 + 透明文字 textarea 叠加 */
.code-editor {
  position: relative;
  border: 1px solid var(--border-default); border-radius: 12px;
  background: var(--bg-surface); overflow: hidden;
  height: 300px;
}
.code-editor:focus-within { border-color: var(--color-brand); }
.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: var(--color-brand); }
.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: var(--color-brand); 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: var(--color-brand);
  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: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.bs-list-pane {
  min-height: 200px;
  position: sticky;
  top: 18px;
}
.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 var(--border-default); border-radius: 10px;
  cursor: pointer; transition: all .12s; background: var(--bg-surface);
}
.bs-list-item:hover { border-color: var(--color-brand); background: var(--bg-surface-subtle); }
.bs-list-item.active { border-color: var(--color-brand); background: var(--color-brand-subtle); 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: var(--text-muted); }
.bs-list-empty { font-size: 13px; color: var(--text-muted); 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: var(--bg-surface);
  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: var(--color-brand); 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: var(--color-brand); background: color-mix(in srgb, var(--bg-surface) 88%, transparent); 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 var(--bg-surface); 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 var(--border-default); 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: var(--color-brand); }
.bs-props-pos { font-size: 12px; color: var(--text-muted); }
.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 var(--border-default); border-radius: 6px; font-size: 12px; }
.bs-mini input[type="color"] { width: 32px; height: 26px; padding: 1px; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-surface); }

/* Generated AI constraints — read-only preview (Phase C / D5) */
.bs-constraints { margin-top: 14px; border: 1px solid var(--border-default); border-radius: 10px; background: var(--bg-page-warm); padding: 12px; }
.bs-constraints-head { display: flex; align-items: center; gap: 10px; }
.bs-constraints-title { font-weight: 700; color: var(--color-brand); font-size: 13px; }
.bs-constraints-badge { font-size: 11px; font-weight: 600; color: #8A6D00; background: rgba(178,106,0,.12); border: 1px solid rgba(178,106,0,.25); border-radius: 999px; padding: 2px 8px; }
.bs-constraints-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.bs-chip { font-size: 11px; color: #475247; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 6px; padding: 2px 8px; }
.bs-constraints-text { margin: 0; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.5; color: #3A4139; background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: 8px; padding: 10px 12px; }

/* Render theme editor (Phase C2) */
.bs-theme { margin-top: 14px; border: 1px solid var(--border-default); border-radius: 10px; background: var(--bg-page-warm); padding: 12px; }
.bs-theme-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.bs-theme-title { font-weight: 700; color: var(--color-brand); font-size: 13px; }
.bs-theme-grid { display: flex; flex-direction: column; gap: 8px; }
.bs-theme-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.bs-theme-label { min-width: 64px; font-size: 12px; font-weight: 600; color: #475247; }
.bs-theme-row select { padding: 4px 6px; border: 1px solid var(--border-default); border-radius: 6px; font-size: 12px; }
.bs-theme-preview { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bs-tp-formula { border-radius: 8px; padding: 8px 12px; font-weight: 500; }
.bs-tp-code { margin: 0; border-radius: 8px; padding: 8px 12px; font-size: 12px; overflow-x: auto; white-space: pre; }
.bs-tp-callout { border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.bs-tp-table { border-collapse: collapse; font-size: 12px; }
.bs-tp-table th, .bs-tp-table td { padding: 4px 10px; }
@media (max-width: 980px) { .bs-theme-preview { grid-template-columns: 1fr; } }

@media (max-width: 980px) {
  .bs-layout { grid-template-columns: 1fr; }
  .bs-list-pane { position: static; }
  .bs-editor-actions { margin-left: 0; }
}

/* Board Styles：全宽双栏（对齐线上 main，仅去掉 max-width，不改 flex 高度链） */
.admin-main:has(#page-board-styles.active) .admin-main__inner {
  max-width: none;
  width: 100%;
}

#page-board-styles .bs-layout {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
}

#page-board-styles .bs-stage {
  width: 100%;
  aspect-ratio: 16 / 9;
}

#page-board-styles .bs-preview-frame {
  height: 480px;
}
