/* ds-5850 · 分镜 v2：一镜一行、连续组卡、图片预览、全集三集窗口、只读审核。
   只写本模块的包装与卡片；颜色、圆角、间距沿用 r12 设计变量。 */

.r12sv2-stage { display: contents; color: var(--r12-ink); }

/* ── 1. 单集：左组名 + 连续六组 ─────────────────────────────── */

/* 底部主控浮在内容上，不占布局：工作区铺满内容区，不再用 --r12-dock-clear 减高，
   也不在底部预留空白。滚动区自己滚动，主控只覆盖不挤压。 */
.r12sv2-stage .r12sv2-single,
.r12sv2-stage .r12sv2-all,
.r12sv2-stage .r12sv2-review { height: 100%; min-height: 0; }

.r12sv2-nav,
.r12sv2-main,
.r12sv2-refs { min-height: 0; overflow: hidden; }

.r12sv2-nav-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 8px;
}

.r12sv2-nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 1px;
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--r12-r-control);
  background: transparent;
  color: var(--r12-ink);
  text-align: left;
  cursor: pointer;
}

.r12sv2-nav-item:hover { background: var(--r12-hover); }
.r12sv2-nav-item.is-active,
.r12sv2-nav-item[aria-pressed='true'] {
  background: var(--r12-selected-bg);
  box-shadow: var(--r12-selected-shadow, none);
}

.r12sv2-nav-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.r12sv2-nav-id {
  flex: none;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  font-weight: 600;
  color: var(--r12-muted);
}

.r12sv2-nav-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--r12-fs-ui);
  line-height: var(--r12-lh-ui);
  font-weight: 600;
}

.r12sv2-nav-meta {
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
  white-space: nowrap;
}

.r12sv2-count {
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  font-weight: 500;
  color: var(--r12-muted);
  white-space: nowrap;
}

.r12sv2-head,
.r12sv2-review-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--r12-line);
}

.r12sv2-head-main { min-width: 0; flex: 1 1 260px; }
.r12sv2-head-main h2,
.r12sv2-review-head h2 {
  margin: 0;
  font-size: var(--r12-fs-title);
  line-height: var(--r12-lh-title);
  font-weight: 600;
  color: var(--r12-ink);
  overflow-wrap: anywhere;
}

.r12sv2-head-main p,
.r12sv2-review-head p {
  margin: 1px 0 0;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

.r12sv2-head-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.r12sv2-head-actions .r12-btn svg { width: 14px; height: 14px; }

.r12sv2-scroll,
.r12sv2-all-scroll,
.r12sv2-review-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
  scroll-padding-block: 16px;
}

.r12sv2-thumb,
.r12sv2-ref-thumb,
.r12sv2-ref-dot {
  scroll-margin-block: 16px;
}

/* ── 2. 组卡与镜头卡 ────────────────────────────────────────── */

.r12sv2-group-card {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-card);
  background: var(--r12-surface-2);
}

.r12sv2-group-head,
.r12sv2-review-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.r12sv2-group-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 200px;
}

.r12sv2-group-title b,
.r12sv2-group-title h3 {
  margin: 0;
  min-width: 0;
  font-size: var(--r12-fs-ui);
  line-height: var(--r12-lh-ui);
  font-weight: 600;
  color: var(--r12-ink);
  overflow-wrap: anywhere;
}

.r12sv2-group-title small {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

.r12sv2-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--r12-muted);
  white-space: nowrap;
}

.r12sv2-group-actions {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.r12sv2-group-actions .r12-btn svg { width: 14px; height: 14px; }

/* 一镜一行：组内三镜纵向排列，不再三列 auto-fit。网格容器同时作为容器查询的参照，
   实际宽度不足时镜头卡在卡内改成上下分区，字号不变。 */
.r12sv2-shot-grid,
.r12sv2-review-shots {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  container-type: inline-size;
}

.r12sv2-shot-card {
  flex: none;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  grid-template-areas: 'head body';
  gap: 8px 12px;
  align-items: start;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-card);
  background: var(--r12-surface);
  overflow: hidden;
}

.r12sv2-shot-head {
  grid-area: head;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.r12sv2-shot-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.r12sv2-thumb {
  position: relative;
  flex: none;
  width: 100%;
  max-width: 190px;
  box-sizing: border-box;
  aspect-ratio: 16 / 10;
  padding: 0;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-media, 8px);
  overflow: hidden;
  background: var(--r12-surface-3);
  cursor: zoom-in;
}

.r12sv2-thumb:hover { border-color: var(--r12-line-strong, var(--r12-line)); }
.r12sv2-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }

.r12sv2-shot-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 卡内宽度不足：镜头图与镜号信息回到上方一行，文本区占满整宽。 */
@container (max-width: 560px) {
  .r12sv2-shot-card { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'head' 'body'; }
  .r12sv2-shot-head { flex-direction: row; align-items: flex-start; gap: 8px; }
  .r12sv2-thumb { width: 104px; max-width: 104px; }
}

.r12sv2-shot-no {
  font-size: var(--r12-fs-ui);
  line-height: var(--r12-lh-ui);
  font-weight: 600;
  color: var(--r12-ink);
}

.r12sv2-shot-framing {
  display: block;
  min-width: 0;
  max-width: 100%;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  font-weight: 600;
  color: var(--r12-ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.r12sv2-shot-meta {
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
  overflow-wrap: anywhere;
}

.r12sv2-shot-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.r12sv2-shot-desc,
.r12sv2-shot-line {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  font-size: var(--r12-fs-ui);
  line-height: var(--r12-lh-ui);
  color: var(--r12-ink);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.r12sv2-shot-line { color: var(--r12-muted); }

.r12sv2-shot-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid var(--r12-line);
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

.r12sv2-shot-cast,
.r12sv2-shot-refs {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.r12sv2-shot-foot b { flex: none; font-weight: 600; color: var(--r12-ink); }

.r12sv2-ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  max-width: 100%;
  padding: 0 6px;
  border-radius: var(--r12-r-pill);
  background: var(--r12-surface-3);
  color: var(--r12-ink);
  overflow-wrap: anywhere;
}

.r12sv2-ref-dot {
  flex: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--r12-surface-2);
  cursor: zoom-in;
}

.r12sv2-ref-dot img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* 可编辑字段：可见名称 + 铺满卡片宽，长句自动换行 */
.r12sv2-field {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  max-width: 100%;
}

.r12sv2-field-name {
  font-size: 11px;
  line-height: 14px;
  color: var(--r12-faint);
}

.r12sv2-field .r12-editable {
  display: block;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  padding: 1px 2px;
  border-radius: 5px;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.r12sv2-field .r12-editable:hover { background: var(--r12-hover); }

/* ── 3. 右侧引用 ────────────────────────────────────────────── */

.r12sv2-refs-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px 10px;
}

.r12sv2-refs .r12-panel-head h3 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r12sv2-ref-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 4px;
  border-radius: var(--r12-r-control);
}

.r12sv2-ref-item:hover { background: var(--r12-hover); }

.r12sv2-ref-thumb {
  flex: none;
  width: 52px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r12-r-media, 8px);
  overflow: hidden;
  background: var(--r12-surface-3);
  cursor: zoom-in;
}

.r12sv2-ref-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.r12sv2-ref-thumb.is-art { display: grid; place-items: center; cursor: default; }
.r12sv2-ref-thumb.is-art svg { width: 100%; height: 100%; }

.r12sv2-ref-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.r12sv2-ref-main b {
  min-width: 0;
  font-size: var(--r12-fs-ui);
  line-height: var(--r12-lh-ui);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r12sv2-ref-main small {
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

/* ── 4. 全集三集窗口 ───────────────────────────────────────── */

.r12sv2-all-panel { min-height: 0; overflow: hidden; }

/* 上一集 / 当前集 / 下一集三段纵向排列；只有当前集内部滚动。 */
.r12sv2-all-window {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px 10px;
}

.r12sv2-adj {
  flex: none;
  align-self: flex-start;
  display: flex;
  align-items: baseline;
  gap: 8px;
  /* 紧凑条不铺满整行：底部主控浮在窗口中线，限宽后整条中心仍在主控左侧可点。 */
  width: min(380px, 100%);
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-control);
  background: var(--r12-surface-2);
  color: var(--r12-ink);
  text-align: left;
  cursor: pointer;
}

.r12sv2-adj:hover { background: var(--r12-hover); }
.r12sv2-adj:focus-visible { outline: 2px solid var(--r12-selected-border); outline-offset: -2px; }

.r12sv2-adj-dir {
  flex: none;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

.r12sv2-adj-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--r12-fs-ui);
  line-height: var(--r12-lh-ui);
  font-weight: 600;
}

.r12sv2-adj-meta {
  flex: none;
  margin-left: auto;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
  white-space: nowrap;
}

/* 当前集占中间剩余高度；头是固定行，滚动只发生在下面这一块。 */
.r12sv2-all-current {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-card);
  background: var(--r12-surface-2);
  overflow: hidden;
}

.r12sv2-all-current:focus { outline: none; }
.r12sv2-all-current:focus-visible { outline: 2px solid var(--r12-selected-border); outline-offset: -2px; }

.r12sv2-all-current-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  border-bottom: 1px solid var(--r12-line);
}

.r12sv2-all-current-head h2 {
  margin: 0;
  font-size: var(--r12-fs-title);
  line-height: var(--r12-lh-title);
  font-weight: 600;
  color: var(--r12-ink);
  overflow-wrap: anywhere;
}

.r12sv2-all-current-head p {
  margin: 1px 0 0;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

.r12sv2-all-current > .r12sv2-all-scroll { flex: 1; min-height: 0; }

/* ── 5. 只读审核 ────────────────────────────────────────────── */

.r12sv2-review-panel { min-height: 0; overflow: hidden; }

.r12sv2-review-stats {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.r12sv2-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-pill);
  background: var(--r12-surface-3);
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
  white-space: nowrap;
}

.r12sv2-stat b {
  font-weight: 600;
  color: var(--r12-ink);
  font-variant-numeric: tabular-nums;
}

.r12sv2-note {
  margin: 0;
  font-size: var(--r12-fs-small);
  line-height: var(--r12-lh-small);
  color: var(--r12-muted);
}

.r12sv2-review-group {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--r12-line);
  border-radius: var(--r12-r-card);
  background: var(--r12-surface-2);
}

/* 审核页也保持一镜一行（.r12sv2-review-shots 已与制作区共用纵向排列）。 */

/* 审核页只有查看/意见/通过，不出现可编辑区 */
.r12sv2-review [contenteditable] { display: none; }

/* ── 6. 悬停缩略预览 ────────────────────────────────────────── */

.r12sv2-hover {
  position: fixed;
  z-index: 13800;
  pointer-events: none;
  overflow: hidden;
  border: 1px solid var(--r12-line-strong, var(--r12-line));
  border-radius: 12px;
  background: var(--r12-surface-3);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .42);
}

.r12sv2-hover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── 7. 弹窗 ───────────────────────────────────────────────── */

.r12sv2-play-figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.r12sv2-play-figure img { width: 100%; max-height: 62vh; object-fit: contain; display: block; border-radius: var(--r12-r-card); background: var(--r12-surface-3); }
.r12sv2-play-figure figcaption { font-size: var(--r12-fs-small); line-height: var(--r12-lh-small); color: var(--r12-muted); }

.r12sv2-prompt-dialog { display: flex; flex-direction: column; gap: 10px; }
.r12sv2-prompt-shot { display: flex; flex-direction: column; gap: 5px; padding: 8px 10px; border: 1px solid var(--r12-line); border-radius: var(--r12-r-card); background: var(--r12-surface-2); }
.r12sv2-prompt-shot-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.r12sv2-prompt-shot-head b { font-weight: 600; color: var(--r12-ink); }
.r12sv2-prompt-shot-head span { font-size: var(--r12-fs-small); line-height: var(--r12-lh-small); color: var(--r12-muted); }
.r12sv2-prompt-cast { margin: 0; font-size: var(--r12-fs-small); line-height: var(--r12-lh-small); color: var(--r12-muted); overflow-wrap: anywhere; }

.r12sv2-comment-form { display: flex; flex-direction: column; gap: 8px; }
.r12sv2-comment-form textarea { width: 100%; box-sizing: border-box; resize: vertical; }

/* ── 8. 窗口较矮时收紧间距 ─────────────────────────────────── */

@media (max-height: 700px) {
  .r12sv2-scroll,
  .r12sv2-all-scroll,
  .r12sv2-review-scroll { gap: 8px; padding: 8px 10px 10px; }
  .r12sv2-group-card { padding: 8px; }
  .r12sv2-shot-card { padding: 8px; }
  .r12sv2-adj { min-height: 32px; padding: 3px 10px; }
}
