/* 需求角标与悬浮业务逻辑面板 */

.req-anchor-host {
  position: relative;
}

[data-req-anchor]:not(.req-anchor-inline) {
  position: relative;
}

.req-anchor-inline {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
}

.req-marker {
  z-index: 40;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #2f7cff;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(47, 124, 255, 0.4);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.req-anchor-host > .req-marker,
[data-req-anchor]:not(.req-anchor-inline) > .req-marker {
  position: absolute;
  top: -8px;
  right: -8px;
}

.req-anchor-inline > .req-marker {
  position: static;
  margin-left: 2px;
}

.req-marker.is-drag-positioned {
  position: absolute !important;
  right: auto !important;
  margin: 0 !important;
}

.req-marker.is-dragging {
  cursor: grabbing;
  z-index: 120;
  box-shadow: 0 4px 14px rgba(47, 124, 255, 0.55);
  transform: scale(1.08);
}

body.req-marker-dragging {
  cursor: grabbing !important;
  user-select: none !important;
}

body.req-marker-dragging * {
  cursor: grabbing !important;
}

.req-anchor-host,
[data-req-anchor] {
  overflow: visible;
}

/* 精讲页：角标不破坏绝对定位的操作提示 / 要点标签 */
.kp-page-hint .req-anchor-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kp-concept-ribbon.req-anchor-inline,
.kp-formula-ribbon.req-anchor-inline {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 考点序号徽章默认 pointer-events:none，挂角标后需可点且盖过展开热区 */
.kp-exam-badge.req-anchor-inline {
  pointer-events: auto;
  z-index: 46;
}

.kp-exam-badge.req-anchor-inline > .req-marker {
  pointer-events: auto;
  transform: rotate(6deg);
}

/* 考点类型角标跟在标签右侧；卡片不再裁切，长标题时标签换到下一行 */
.kp-exam-type-host.req-anchor-inline {
  pointer-events: auto;
  z-index: 46;
  overflow: visible;
}

.kp-exam-type-host.req-anchor-inline > .req-marker {
  position: static;
  pointer-events: auto;
  margin-left: 2px;
}

.kp-foot {
  position: relative;
}

.kp-foot > .req-marker-slot {
  position: absolute;
  right: -4px;
  top: -8px;
}

/* 解析角标旁挂，不改解析按钮自身布局 */
.kp-exam-analysis-slot {
  position: absolute;
  top: -4px;
  right: 56px;
  z-index: 3;
}

/* 题干 / 解题要点：角标绝对贴靠，不改为 inline-flex */
.kp-example-stem[data-req-anchor] > .req-marker,
.kp-keypoints-title[data-req-anchor] > .req-marker {
  top: -10px;
  right: -6px;
}

.req-marker:hover,
.req-marker.is-active {
  background: #1a5fe0;
  transform: scale(1.06);
}

.req-marker.is-editing {
  visibility: hidden;
}

.req-marker-input {
  z-index: 41;
  width: 28px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #2f7cff;
  background: #fff;
  color: #1a5fe0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(47, 124, 255, 0.35);
  flex-shrink: 0;
  -moz-appearance: textfield;
}

.req-marker-input::-webkit-outer-spin-button,
.req-marker-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.req-anchor-host > .req-marker-input,
[data-req-anchor]:not(.req-anchor-inline) > .req-marker-input {
  position: absolute;
  top: -8px;
  right: -8px;
}

.req-list-scroll-slot > .req-marker-input {
  position: static;
}

.header-action .req-anchor-inline {
  min-height: 32px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 16px 8px 8px;
}

.section-title-row .section-title {
  padding: 0;
  margin-bottom: 0;
}

.req-marker-slot {
  width: 20px;
  height: 20px;
  min-width: 20px;
  flex-shrink: 0;
}

.papers-title-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.req-marker-slot > .req-marker {
  margin-left: 0;
}

/* 章节页：已学习 → 状态角标 → 列表角标 成组，避免被 footer space-between 拆开 */
.resource-footer-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-shrink: 0;
}

.chapter-req-pair {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 20px;
  flex-shrink: 0;
}

.chapter-req-pair .req-marker-slot {
  position: relative;
}

.chapter-req-pair .req-marker-slot > .req-marker {
  margin-left: 0;
}

/* 列表区域滚动角标：独立锚点内收，避免贴边被 overflow 裁切 */
.req-list-scroll-slot {
  position: absolute;
  top: 58px;
  right: 52px;
  z-index: 45;
  width: 20px;
  height: 20px;
  min-width: 20px;
}

.req-list-scroll-slot > .req-marker {
  position: static;
  margin-left: 0;
}

.source-tab em.req-anchor-inline {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.req-float-card {
  position: fixed;
  z-index: 1200;
  width: 360px;
  max-width: calc(100vw - 16px);
  height: 420px;
  max-height: calc(100vh - 16px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d7e8de;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 50, 36, 0.18);
  overflow: hidden;
}

.req-float-card[hidden] {
  display: none !important;
}

.req-float-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  background: linear-gradient(180deg, #eef8f2 0%, #fff 100%);
  border-bottom: 1px solid #e5efe9;
  cursor: move;
  user-select: none;
}

.req-float-id {
  font-size: 11px;
  font-weight: 700;
  color: #2f7cff;
  letter-spacing: 0.02em;
}

.req-float-title {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  color: #1f3d2e;
  line-height: 1.35;
  user-select: text;
  cursor: text;
}

.req-float-hint {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: #7a9486;
  font-weight: 500;
  user-select: none;
}

.req-float-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #6b8576;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.req-float-close:hover {
  background: #eef5f0;
  color: #1f3d2e;
}

.req-float-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 18px;
}

.req-float-section + .req-float-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e2eee7;
}

.req-float-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #2f6b4d;
}

.req-float-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.req-float-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 6px;
  align-items: start;
  font-size: 13px;
  line-height: 1.55;
  color: #33483d;
}

.req-float-item-no {
  color: #6f9b84;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.req-review-tag {
  color: #e67e22;
  font-weight: 700;
}

.req-float-empty {
  color: #8a9a90;
  font-size: 13px;
}

.req-float-item-text.is-editing,
.req-float-title.is-editing,
.req-float-section h4.is-editing,
.prd-detail [data-edit-field].is-editing {
  outline: 1px dashed #2f7cff;
  outline-offset: 2px;
  background: #f4f8ff;
  border-radius: 4px;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
}

.req-float-item-text,
.prd-logic-section li > span:last-child {
  white-space: pre-wrap;
  word-break: break-word;
}

.prd-writeback-toast {
  position: fixed;
  z-index: 1400;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 10px;
  background: #1f3d2e;
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(20, 50, 36, 0.22);
}

.prd-writeback-toast[data-kind="err"] {
  background: #9b3b32;
}

.prd-writeback-toast[hidden] {
  display: none !important;
}

.req-float-resizer {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, #b7d2c3 50%, #b7d2c3 60%, transparent 60%),
    linear-gradient(135deg, transparent 68%, #b7d2c3 68%, #b7d2c3 78%, transparent 78%);
}
