/* 绘梦AI · 角色库（人物音色 / 场景图库）样式 */
body { overflow: hidden; }

.r-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: var(--card);
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.r-tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.r-tab {
  border: none; background: transparent; cursor: pointer;
  padding: 7px 15px; border-radius: 8px; font-size: 14px; color: var(--muted);
  font-family: inherit; transition: all .15s;
}
.r-tab:hover { color: var(--text); }
.r-tab.active { background: var(--card); color: var(--brand); font-weight: 600; box-shadow: 0 1px 4px rgba(31,35,41,.08); }
.r-tab-count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  font-size: 11px; line-height: 17px; border-radius: 999px;
  background: rgba(108,92,231,.1); color: var(--brand); vertical-align: 1px;
}
.r-search {
  flex: 1; max-width: 380px; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; height: 36px; color: var(--muted); font-size: 13px;
}
.r-search input { flex: 1; border: none; background: transparent; outline: none; font-size: 13px; color: var(--text); font-family: inherit; }
.r-actions { margin-left: auto; display: flex; gap: 8px; }

.r-body { flex: 1; display: flex; min-height: 0; }

/* ---- 左侧 ---- */
.r-side {
  width: 232px; flex: 0 0 232px; background: var(--card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0;
}
.r-side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; font-size: 13px; }
.r-side-list { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }
.r-side-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: transparent; cursor: pointer; text-align: left;
  padding: 9px 10px; border-radius: 9px; font-size: 13px; color: var(--text);
  font-family: inherit; margin-bottom: 2px;
}
.r-side-item:hover { background: var(--bg); }
.r-side-item.active { background: rgba(108,92,231,.09); color: var(--brand); font-weight: 600; }
.r-side-item .r-dot { width: 7px; height: 7px; border-radius: 50%; background: #c9cede; flex: 0 0 auto; }
.r-side-item.active .r-dot { background: var(--brand); }
.r-side-item .r-count { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 400; }
.r-side-item .r-del {
  margin-left: 4px; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 0 2px; opacity: 0; transition: opacity .15s;
}
.r-side-item:hover .r-del { opacity: 1; }
.r-side-item .r-del:hover { color: var(--err); }
.r-side-foot { padding: 12px 14px; border-top: 1px solid var(--border); }
.r-tip { font-size: 11.5px; line-height: 1.65; color: var(--muted); background: var(--bg); border-radius: 9px; padding: 9px 11px; }
.r-tip b { color: var(--text); font-weight: 600; }

/* ---- 主区 ---- */
.r-main { flex: 1; overflow-y: auto; padding: 18px 20px 40px; min-width: 0; }
.r-section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 2px 0 14px; }
.r-section-title b { color: var(--text); font-size: 15px; }

.r-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 14px; }
.r-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .16s, box-shadow .16s;
}
.r-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(31,35,41,.1); }
.r-photo {
  position: relative; width: 100%; aspect-ratio: 4 / 5; background: #eef0f6; cursor: pointer; overflow: hidden;
}
.r-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.r-photo .r-empty-photo {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--muted); font-size: 12.5px; background: repeating-linear-gradient(45deg,#f7f8fb,#f7f8fb 10px,#f1f3f8 10px,#f1f3f8 20px);
}
.r-photo .r-empty-photo span:first-child { font-size: 26px; }
.r-photo-tags { position: absolute; left: 9px; top: 9px; display: flex; gap: 6px; }
.r-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.9);
  color: var(--text); font-weight: 600; backdrop-filter: blur(4px);
}
.r-badge.voice-ok { color: #0b7a4b; background: rgba(224,250,238,.94); }
.r-badge.voice-no { color: #b0541a; background: rgba(255,244,230,.94); }
.r-photo-hint {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px;
  font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.55));
  opacity: 0; transition: opacity .16s;
}
.r-card:hover .r-photo-hint { opacity: 1; }

.r-card-body { padding: 11px 13px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.r-name-row { display: flex; align-items: center; gap: 6px; }
.r-name-row h3 { font-size: 14.5px; font-weight: 650; cursor: text; }
.r-name-row .r-cat { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 1px 6px; }
.r-name-row .r-more { margin-left: auto; border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 15px; }

.r-voice {
  display: flex; align-items: center; gap: 7px; font-size: 12px;
  background: #f8f9fd; border: 1px solid var(--border); border-radius: 9px; padding: 6px 8px;
}
.r-voice.empty { color: var(--muted); border-style: dashed; background: transparent; }
.r-voice .r-play {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; border: none;
  background: var(--brand); color: #fff; cursor: pointer; font-size: 11px; display: grid; place-items: center;
}
.r-voice .r-voice-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-voice .r-link { border: none; background: transparent; color: var(--brand); cursor: pointer; font-size: 11.5px; }

.r-phrases { display: flex; flex-wrap: wrap; gap: 5px; }
.r-phrase {
  font-size: 11.5px; padding: 3px 8px; border-radius: 7px; background: var(--bg);
  color: var(--text); border: 1px solid var(--border); cursor: pointer; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.r-phrase:hover { border-color: var(--brand); color: var(--brand); }
.r-no-phrase { font-size: 11.5px; color: var(--muted); }

.r-card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.r-card-actions .btn { flex: 1; font-size: 12px; padding: 6px 8px; }
.r-card-actions .btn.icon { flex: 0 0 auto; width: 34px; padding: 0; }

/* ---- 场景 ---- */
.r-scene { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.r-scene-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.r-scene-head h3 { font-size: 14px; font-weight: 650; }
.r-scene-head .r-count { font-size: 11.5px; color: var(--muted); }
.r-scene-head .r-scene-acts { margin-left: auto; display: flex; gap: 6px; }
.r-scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 14px; }
.r-img-card { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: #fff; }
.r-img-card .r-img-wrap { position: relative; aspect-ratio: 16 / 10; background: #eef0f6; }
.r-img-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.r-img-card .r-img-acts {
  position: absolute; inset: auto 0 0 0; display: flex; gap: 5px; padding: 7px;
  background: linear-gradient(transparent, rgba(0,0,0,.5)); opacity: 0; transition: opacity .15s;
}
.r-img-card:hover .r-img-acts { opacity: 1; }
.r-img-card .r-img-acts button {
  border: none; border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer;
  background: rgba(255,255,255,.92); color: var(--text); font-family: inherit;
}
.r-img-card .r-img-acts button.p { background: var(--brand); color: #fff; }
.r-img-card .r-desc { font-size: 11.5px; color: var(--muted); line-height: 1.55; padding: 8px 9px; min-height: 34px; cursor: text; }
.r-img-card .r-desc.has { color: var(--text); }
.r-img-card .r-desc:hover { background: var(--bg); }

.r-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 60px 20px; line-height: 2; }
.r-empty b { color: var(--text); }

/* ---- 弹窗 ---- */
.r-mask {
  position: fixed; inset: 0; background: rgba(20,22,30,.42); z-index: 300;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
/* v4：输入弹窗必须盖过详情弹窗（同 300 时 DOM 靠后的 r-detail 会把它压住，「添加台词」看似无反应） */
#r-modal.r-mask { z-index: 400; }
.r-modal-box {
  width: min(440px, 100%); background: var(--card); border-radius: 16px; padding: 22px;
  box-shadow: 0 24px 60px rgba(16,20,30,.24);
}
.r-modal-box h3 { font-size: 16px; margin-bottom: 4px; }
.r-modal-sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.r-modal-box input, .r-modal-box textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
  font-size: 13.5px; font-family: inherit; color: var(--text); background: var(--bg); outline: none; margin-bottom: 10px;
}
.r-modal-box input:focus, .r-modal-box textarea:focus { border-color: var(--brand); background: #fff; }
.r-modal-box textarea { resize: vertical; min-height: 88px; line-height: 1.6; }
.r-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.r-detail-box {
  width: min(880px, 100%); max-height: 90vh; overflow-y: auto; background: var(--card);
  border-radius: 16px; padding: 20px 22px; box-shadow: 0 24px 60px rgba(16,20,30,.24);
}
.r-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.r-detail-head h3 { font-size: 17px; }
.r-detail-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; }
.r-field-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.r-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.r-mini-photo { position: relative; aspect-ratio: 3 / 4; border-radius: 9px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: #eef0f6; }
.r-mini-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.r-mini-photo.is-default { border-color: var(--brand); }
.r-mini-photo .r-mini-del {
  position: absolute; right: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; cursor: pointer; display: grid; place-items: center;
}
.r-mini-photo .r-def-tag {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center;
  padding: 2px; background: rgba(108,92,231,.9); color: #fff;
}
.r-upload-line { display: inline-block; margin-top: 10px; }
.r-upload-line .btn { cursor: pointer; }
.r-voice-box {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg);
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
}
.r-voice-box.empty { color: var(--muted); border-style: dashed; background: transparent; }
.r-phrase-list { display: flex; flex-direction: column; gap: 6px; }
.r-phrase-row {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
}
.r-phrase-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-phrase-row button { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 12px; }
.r-phrase-row button:hover { color: var(--err); }
.r-detail-actions { display: flex; align-items: center; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.btn.danger-ghost { color: var(--err); border: 1px solid #f5c6c2; background: #fff; }
.btn.danger-ghost:hover { background: #fff4f3; }

/* ---- toast ---- */
.r-toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #23262f; color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .22s; z-index: 500; max-width: 80vw;
}
.r-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

@media (max-width: 900px) {
  .r-side { display: none; }
  .r-detail-grid { grid-template-columns: 1fr; }
  .r-search { display: none; }
}

/* ===== v2（11-01）：拖拽进剪映 ===== */
.r-photo, .r-mini-photo, .r-img-wrap { cursor: grab; -webkit-user-drag: element; user-select: none; }
.r-photo:active, .r-mini-photo:active, .r-img-wrap:active { cursor: grabbing; }
.r-photo img, .r-mini-photo img, .r-img-wrap img { pointer-events: none; } /* 拖父容器，别让原生 img 拖拽抢事件 */
.r-dl-fallback { color: #8a7bd8; }

/* ===== v3：剪映导入说明条 ===== */
.r-jy-hint { margin: 12px 0 0; padding: 10px 12px; background: #f4f2ff; border: 1px solid #e2dcff; border-radius: 10px; font-size: 12.5px; line-height: 1.65; color: #5b4f9e; }
.r-jy-hint b { color: #3f3480; font-weight: 600; }

/* ---- v5：宫格选择 / 分集 ---- */
.r-grid-pick { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--muted,#889); margin-right:8px; white-space:nowrap; }
.r-grid-pick select { border:1px solid var(--border,#dde); background:#fff; border-radius:8px; padding:5px 8px; font-size:12px; cursor:pointer; }
.r-side-sec { font-size:11px; color:var(--muted,#889); padding:12px 10px 4px; letter-spacing:1px; }
.r-dot.ep { background:#f59e0b; }
.r-ep-badge { display:inline-block; font-size:11px; padding:1px 7px; border-radius:999px; background:#fef3c7; color:#92400e; margin-left:6px; vertical-align:middle; }
.r-ep-row { display:flex; align-items:center; gap:8px; margin-top:14px; }
.r-ep-row label { font-size:12px; color:var(--muted,#889); white-space:nowrap; }
.r-ep-row input { flex:1; border:1px solid var(--border,#dde); border-radius:8px; padding:6px 10px; font-size:13px; }
.r-ep-row input:focus { outline:none; border-color:#7c5cff; }
.r-phrase-row span { cursor:pointer; }
.r-phrase-row span:hover { color:#7c5cff; }

/* ---- v6：分集一级分组 ---- */
.r-ep-sec { display:flex; align-items:center; justify-content:space-between; }
.r-ep-add { border:none; background:#eef0ff; color:#5b4dcf; width:20px; height:20px; border-radius:6px; cursor:pointer; font-size:13px; line-height:1; padding:0; }
.r-ep-add:hover { background:#dfe2ff; }
.r-ep-head { display:flex; align-items:center; gap:10px; background:#f4f2ff; border:1px solid #e3ddff; border-radius:12px; padding:10px 14px; margin-bottom:14px; font-size:14px; }
.r-ep-head b { font-size:15px; }

/* ---- v7：分集成员挑选弹窗 ---- */
.r-ep-pick-mask { position:fixed; inset:0; background:rgba(15,18,34,.45); z-index:420; display:flex; align-items:center; justify-content:center; }
.r-ep-pick { background:#fff; border-radius:16px; width:min(480px,92vw); max-height:78vh; display:flex; flex-direction:column; padding:16px 18px; box-shadow:0 18px 60px rgba(0,0,0,.25); }
.r-ep-pick-head { display:flex; align-items:center; justify-content:space-between; font-size:15px; }
.r-ep-pick-head .rp-close { border:none; background:#f1f3f7; width:26px; height:26px; border-radius:8px; cursor:pointer; font-size:13px; }
.r-ep-pick-tip { font-size:12px; color:#8792a8; margin:6px 0 10px; }
.r-ep-pick-list { overflow:auto; flex:1; border:1px solid #eef0f5; border-radius:12px; padding:6px; }
.r-ep-pick-row { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:10px; cursor:pointer; }
.r-ep-pick-row:hover { background:#f6f5ff; }
.r-ep-pick-row img { width:44px; height:44px; object-fit:cover; border-radius:8px; }
.r-ep-pick-ph { width:44px; height:44px; display:flex; align-items:center; justify-content:center; background:#f1f3f7; border-radius:8px; font-size:18px; }
.r-ep-pick-name { font-size:13px; font-weight:600; }
.r-ep-pick-sub { font-size:12px; color:#8792a8; }
.r-ep-pick-row input[type=checkbox] { width:16px; height:16px; cursor:pointer; }
.r-ep-pick-empty { padding:28px 10px; text-align:center; color:#8792a8; font-size:13px; }
.r-ep-pick-foot { display:flex; align-items:center; justify-content:flex-end; gap:8px; margin-top:12px; }

/* v8：外部图片拖入目标高亮（微信/资源管理器 → 角色库/场景库） */
.r-drop-hot { outline: 2px dashed #8b7cf6; outline-offset: -4px; border-radius: 10px; background: rgba(139, 124, 246, 0.08); }

/* ===== v9：场景卡宫格 + 全屏看图器 ===== */
.r-scene-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 14px; }
.r-scene-card { border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.r-scene-card-head { display: flex; align-items: center; gap: 6px; padding: 9px 11px 0; font-size: 12.5px; }
.r-scene-card-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-scene-card-imgs { padding: 9px 11px; }
.r-scene-card-imgs .r-img-card .r-img-wrap { aspect-ratio: 4 / 3; }
.r-scene-card-foot { display: flex; gap: 6px; padding: 0 11px 11px; margin-top: auto; align-items: center; }
#r-viewer { position: fixed; inset: 0; z-index: 500; background: rgba(12,12,22,.88); display: none; align-items: center; justify-content: center; cursor: zoom-out; }
#r-viewer.show { display: flex; }
#r-viewer img { max-width: 92vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 12px 48px rgba(0,0,0,.5); transition: transform .12s; transform-origin: center; }
#r-viewer #r-viewer-close { position: absolute; right: 18px; top: 14px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,.16); color: #fff; font-size: 16px; cursor: pointer; }
#r-viewer #r-viewer-close:hover { background: rgba(255,255,255,.3); }
.r-mini-photo .r-mini-zoom { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 10px; cursor: pointer; display: grid; place-items: center; }
