/* 纸本名师红笔手批与动态 SVG 贝塞尔连线样式 */

.rp-stage {
  position: relative;
  padding: 0;
  overflow: hidden;
  background: var(--bg-card, #FFFFFF);
}

/* 顶部双栏文房眉标 */
.rp-stage-head {
  display: grid;
  grid-template-columns: minmax(0, 62%) minmax(0, 38%);
  border-bottom: 1px solid var(--border-soft, #E8E0D2);
  background: var(--bg-subtle, #F3EFE7);
}

.rp-stage-head-left,
.rp-stage-head-right {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 12px 24px;
}

.rp-stage-head-left {
  border-right: 1px solid var(--border-soft, #E8E0D2);
}

.rp-head-stamp {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--redpen, #C43B2B);
  letter-spacing: 0.04em;
}

.rp-head-sub {
  font-size: 12.5px;
  color: var(--ink-muted, #868D88);
}

/* 逐段左稿右批舞台 */
.rp-rows {
  position: relative;
  z-index: 1;
}

.rp-para-row {
  display: grid;
  grid-template-columns: minmax(0, 62%) minmax(0, 38%);
  border-bottom: 1px dashed var(--border-soft, #E8E0D2);
}

.rp-para-row:last-child {
  border-bottom: 0;
}

/* 左 62%：纸本原稿区 */
.rp-sheet-cell {
  position: relative;
  padding: 24px 34px 26px 32px;
  background: #FFFDF9;
  border-right: 1px solid color-mix(in srgb, var(--redpen, #C43B2B) 22%, var(--border-soft, #E8E0D2));
  min-width: 0;
}

[data-theme="dark"] .rp-sheet-cell {
  background: #25221E;
}

/* 稿纸左侧淡淡朱红装饰边线 */
.rp-sheet-cell::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 14px;
  width: 2px;
  background: color-mix(in srgb, var(--redpen, #C43B2B) 16%, transparent);
}

.rp-para-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  font-size: 12.8px;
  color: var(--ink-muted);
}

.rp-para-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--redpen-soft);
  color: var(--redpen);
  font-weight: 700;
  font-size: 12.5px;
}

.rp-para-name {
  font-weight: 600;
  color: var(--ink-secondary);
}

.rp-para-wc {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-muted);
}

/* 原稿正文：大行距 2.85 保证行间楷体批注充裕净空，永不与上一行碰撞 */
.rp-prose {
  font-size: 18.5px;
  line-height: 2.85;
  color: var(--ink-primary);
  text-indent: 2em;
  letter-spacing: 0.02em;
  word-break: break-word;
  padding-top: 8px;
}

/* 老师红笔圈赞：优雅红点着重号 */
.rp-praise-hit {
  text-emphasis: filled dot;
  text-emphasis-position: under;
  text-emphasis-color: color-mix(in srgb, var(--redpen, #C43B2B) 78%, transparent);
  -webkit-text-emphasis: filled dot;
  -webkit-text-emphasis-position: under;
  -webkit-text-emphasis-color: color-mix(in srgb, var(--redpen, #C43B2B) 78%, transparent);
  border-radius: 3px;
  transition: background-color 0.15s ease;
}

.rp-praise-hit:hover {
  background: var(--redpen-soft);
}

/* 公共红笔标记交互基类 */
.rp-mark {
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* 红笔序号小圆圈 */
.rp-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  margin-left: 2px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--redpen) 68%, transparent);
  background: var(--redpen-soft);
  color: var(--redpen);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: super;
  text-indent: 0;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.rp-mark.is-ph .rp-num {
  border-color: var(--diff-ph-border);
  background: var(--diff-ph-bg);
  color: var(--diff-ph-ink);
}

/* 1. 纯删除 */
.rp-del-strike {
  color: var(--ink-muted);
  text-decoration: line-through;
  text-decoration-color: var(--redpen);
  text-decoration-thickness: 1.55px;
}

.rp-del:hover,
.rp-del.is-hover {
  background: var(--redpen-soft);
}

/* 2. 短词行间楷体替换（关键：text-indent: 0 清除继承缩进，按字数留足水平净空） */
.rp-inline-rep {
  position: relative;
  display: inline-block;
  text-indent: 0;
  line-height: 1.25;
  padding: 0 3px;
  margin: 0 2px;
  min-width: calc(var(--k-len, 3) * 0.82em);
  text-align: center;
  vertical-align: baseline;
}

/* 3. 短词行间楷体增补 */
.rp-inline-ins {
  position: relative;
  display: inline-block;
  text-indent: 0;
  line-height: 1.25;
  padding: 0 4px;
  margin: 0 2px;
  min-width: calc(var(--k-len, 3) * 0.78em);
  text-align: center;
  vertical-align: baseline;
}

.rp-kai-above {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--redpen);
  letter-spacing: 0.02em;
  pointer-events: none;
  padding: 1px 5px;
  border-radius: 4px;
}

.rp-kai-above.is-ph {
  color: var(--diff-ph-ink);
  background: var(--diff-ph-bg);
  border-bottom: 1.5px dashed var(--diff-ph-border);
}

.rp-caret {
  display: inline-block;
  color: var(--redpen);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
}

.rp-inline-ins.is-ph .rp-caret {
  color: var(--diff-ph-ink);
}

/* 4. 长句波浪底线：原文不涂删、一字不挪 */
.rp-wave {
  padding: 2px 2px;
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: color-mix(in srgb, var(--redpen) 76%, transparent);
  text-decoration-thickness: 1.4px;
  text-underline-offset: 5px;
}

.rp-wave.is-ph {
  text-decoration-color: var(--diff-ph-border);
  background: color-mix(in srgb, var(--diff-ph-bg) 55%, transparent);
}

/* 长段增补插入点胶囊 */
.rp-ins-anchor {
  display: inline-block;
  text-indent: 0;
  margin: 0 3px;
  vertical-align: 1px;
}

.rp-caret-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--redpen-soft);
  border: 1px solid var(--redpen-border);
  color: var(--redpen);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.rp-ins-anchor.is-ph .rp-caret-pill {
  background: var(--diff-ph-bg);
  border-color: var(--diff-ph-border);
  color: var(--diff-ph-ink);
}

.rp-caret-sym {
  font-size: 13.5px;
}

.rp-num-inline {
  font-size: 11px;
}

/* 悬停与选中高亮状态 */
.rp-mark:hover,
.rp-mark.is-hover {
  background: var(--redpen-soft);
}

.rp-mark.is-ph:hover,
.rp-mark.is-ph.is-hover {
  background: var(--diff-ph-bg);
}

.rp-mark.is-active {
  background: var(--redpen-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--redpen) 70%, transparent);
}

.rp-mark.is-ph.is-active {
  background: var(--diff-ph-bg);
  box-shadow: 0 0 0 2px var(--diff-ph-border);
}

.rp-mark.is-active .rp-num,
.rp-mark.is-hover .rp-num {
  background: var(--redpen);
  border-color: var(--redpen);
  color: #FFFFFF;
  transform: scale(1.08);
}

.rp-mark.is-ph.is-active .rp-num,
.rp-mark.is-ph.is-hover .rp-num {
  background: var(--diff-ph-ink);
  border-color: var(--diff-ph-ink);
  color: #FFFFFF;
}

.rp-mark.is-active .rp-caret-pill {
  background: var(--redpen);
  border-color: var(--redpen);
  color: #FFFFFF;
}

.rp-mark.is-ph.is-active .rp-caret-pill {
  background: var(--diff-ph-ink);
  border-color: var(--diff-ph-ink);
  color: #FFFFFF;
}

/* 段末红笔圈赞评语 */
.rp-praise-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 16px;
  padding: 9px 13px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--redpen-soft) 65%, transparent);
  color: var(--redpen);
  font-size: 14.5px;
  line-height: 1.65;
}

.rp-praise-circle {
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.rp-praise-label {
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================
   右 38%：老师红笔旁批卡片流
   ============================================================ */
.rp-margin-cell {
  padding: 20px 20px 24px 26px;
  background: color-mix(in srgb, var(--bg-subtle) 58%, var(--bg-card));
  min-width: 0;
}

.rp-cards-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.rp-card {
  position: relative;
  padding: 12px 14px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.rp-card:hover,
.rp-card.is-hover {
  border-color: color-mix(in srgb, var(--redpen) 55%, var(--border-soft));
  background: color-mix(in srgb, var(--redpen-soft) 32%, var(--bg-card));
}

.rp-card.is-ph:hover,
.rp-card.is-ph.is-hover {
  border-color: var(--diff-ph-border);
  background: color-mix(in srgb, var(--diff-ph-bg) 45%, var(--bg-card));
}

.rp-card.is-active {
  border-color: var(--redpen);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--redpen) 20%, transparent), var(--shadow-float);
  background: color-mix(in srgb, var(--redpen-soft) 45%, var(--bg-card));
}

.rp-card.is-ph.is-active {
  border-color: var(--diff-ph-border);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--diff-ph-border) 28%, transparent), var(--shadow-float);
  background: color-mix(in srgb, var(--diff-ph-bg) 60%, var(--bg-card));
}

/* 卡片左缘红笔连线锚点圆点 */
.rp-card-dot {
  position: absolute;
  left: -4px;
  top: 22px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--redpen) 55%, var(--bg-card));
  border: 1.5px solid var(--bg-card);
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.rp-card.is-ph .rp-card-dot {
  background: var(--diff-ph-border);
}

.rp-card.is-active .rp-card-dot,
.rp-card.is-hover .rp-card-dot {
  background: var(--redpen);
  transform: scale(1.3);
}

.rp-card.is-ph.is-active .rp-card-dot,
.rp-card.is-ph.is-hover .rp-card-dot {
  background: var(--diff-ph-ink);
}

.rp-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.rp-card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--redpen-soft);
  color: var(--redpen);
  font-size: 11.5px;
  font-weight: 700;
}

.rp-card.is-ph .rp-card-num {
  background: var(--diff-ph-bg);
  color: var(--diff-ph-ink);
}

.rp-card.is-active .rp-card-num {
  background: var(--redpen);
  color: #FFFFFF;
}

.rp-card.is-ph.is-active .rp-card-num {
  background: var(--diff-ph-ink);
  color: #FFFFFF;
}

.rp-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-primary);
}

.rp-card-op-mini {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-muted);
}

.rp-card-ph-pill {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--diff-ph-bg);
  border: 1px dashed var(--diff-ph-border);
  color: var(--diff-ph-ink);
  font-size: 11px;
  font-weight: 600;
}

/* 老师红笔楷体改写句 */
.rp-card-rewrite {
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--redpen-soft);
  border-left: 2.5px solid var(--redpen);
  color: var(--redpen);
  font-size: 15px;
  line-height: 1.65;
  margin-bottom: 8px;
}

.rp-card-rewrite.is-del {
  background: var(--bg-subtle);
  border-left-color: var(--ink-muted);
  color: var(--ink-secondary);
}

.rp-card-rewrite.is-ph {
  background: var(--diff-ph-bg);
  border-left-color: var(--diff-ph-border);
  color: var(--diff-ph-ink);
}

.rp-rw-prefix {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  margin-right: 3px;
  opacity: 0.88;
}

.rp-card-explain {
  font-size: 13.2px;
  line-height: 1.66;
  color: var(--ink-secondary);
}

.rp-card-hint {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--diff-ph-border);
  font-size: 12.4px;
  line-height: 1.58;
  color: var(--diff-ph-ink);
}

.rp-hint-label {
  font-weight: 700;
}

.rp-margin-empty {
  padding: 16px;
  border-radius: 8px;
  border: 1px dashed var(--border-soft);
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* ============================================================
   透明叠加动态 SVG 三次贝塞尔连线层
   ============================================================ */
.rp-wires {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.rp-wire-path {
  fill: none;
  stroke: var(--redpen, #C43B2B);
  stroke-width: 1.25px;
  stroke-opacity: 0.3;
  stroke-linecap: round;
  transition: stroke-opacity 0.16s ease, stroke-width 0.16s ease;
}

.rp-wire-group.is-ph .rp-wire-path {
  stroke: var(--diff-ph-border, #D9A13B);
  stroke-dasharray: 4 3;
  stroke-opacity: 0.48;
}

.rp-wire-dot {
  fill: var(--redpen, #C43B2B);
  fill-opacity: 0.38;
  transition: fill-opacity 0.16s ease;
}

.rp-wire-group.is-ph .rp-wire-dot {
  fill: var(--diff-ph-border, #D9A13B);
  fill-opacity: 0.55;
}

.rp-wire-group.is-hover .rp-wire-path {
  stroke-opacity: 0.72;
  stroke-width: 1.75px;
}

.rp-wire-group.is-hover .rp-wire-dot {
  fill-opacity: 0.85;
}

.rp-wire-group.is-active .rp-wire-path {
  stroke-opacity: 0.96;
  stroke-width: 2.2px;
  stroke-dasharray: none;
}

.rp-wire-group.is-ph.is-active .rp-wire-path {
  stroke: var(--diff-ph-ink, #7A500A);
  stroke-dasharray: 5 3;
}

.rp-wire-group.is-active .rp-wire-dot {
  fill-opacity: 1;
}

/* ============================================================
   窄屏（<860px）：收拢为流畅单列纸本与段落紧跟旁批
   ============================================================ */
@media (max-width: 859px) {
  .rp-stage-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .rp-stage-head-left {
    border-right: 0;
    padding: 12px 16px;
  }

  .rp-stage-head-right {
    display: none;
  }

  .rp-para-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .rp-sheet-cell {
    padding: 18px 18px 18px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .rp-sheet-cell::before {
    left: 9px;
  }

  .rp-prose {
    font-size: 17px;
    line-height: 2.75;
  }

  .rp-margin-cell {
    padding: 14px 16px 18px;
  }

  .rp-card-dot {
    display: none;
  }

  .rp-wires {
    display: none;
  }
}
