/* ==========================================================================
   数字人工作室（AiMark · 智能创作 → 数字人）
   布局参考业界成熟的数字人控制台：左侧形象库 / 中间画布预览 / 右侧属性面板 /
   底部逐句时间轴。配色沿用 app.css 的浅色设计令牌。
   ========================================================================== */

.dh-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 18px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.dh-tab {
    padding: 10px 16px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
}

.dh-tab:hover { color: var(--text); background: #eef2f8; }

.dh-tab.active {
    background: #fff;
    border-color: var(--border);
    color: var(--primary);
    font-weight: 600;
    margin-bottom: -1px;
    box-shadow: 0 -2px 0 var(--primary) inset;
}

/* ---------- 三栏工作室 ---------- */

.dh-studio {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 318px;
    gap: 16px;
    align-items: start;
}

.dh-live {
    display: grid;
    grid-template-columns: 262px minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
}

.dh-rail,
.dh-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.dh-rail h3,
.dh-panel h3 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dh-rail h3:not(:first-child),
.dh-panel h3:not(:first-child) { margin-top: 18px; }

.dh-rail-sub { font-size: 11px; color: var(--muted); margin: -4px 0 10px; line-height: 1.5; }

/* ---------- 形象卡 ---------- */

.dh-avatars { display: flex; flex-direction: column; gap: 8px; }

.dh-avatar-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.dh-avatar-card:hover { border-color: #bfd4f5; background: #f8fbff; }

.dh-avatar-card.active {
    border-color: var(--primary);
    background: #f2f8ff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .14);
}

.dh-thumb-art {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 9px;
    overflow: hidden;
    background: #eef2f9;
}

.dh-thumb-art svg { display: block; }

.dh-avatar-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.dh-avatar-sub {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.35;
    margin-top: 1px;
}

/* ---------- 舞台 ---------- */

.dh-stage-wrap { min-width: 0; }

.dh-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #d9e2f0;
    background: #e9eef7;
    box-shadow: 0 8px 24px rgba(23, 37, 84, .08);
}

.dh-canvas-inner,
.dh-svg { width: 100%; height: 100%; display: block; }

/* 真人照片：底图 + 嘴/眼局部补丁画布 */
.dh-photo-mode {
    position: relative;
    overflow: hidden;
    background: #0b1220;
}

.dh-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* 不能给底图单独加动效，否则和补丁画布错位 */
}

.dh-patch {
    position: absolute;
    pointer-events: none;
    display: block;
}
}

.dh-overlay { position: absolute; inset: 0; pointer-events: none; }

.dh-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .62);
    color: #fff;
    font-size: 11px;
    letter-spacing: .02em;
    backdrop-filter: blur(4px);
}

.dh-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, .9);
}

.dh-state {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(148, 163, 184, .5);
    color: #334155;
    font-size: 11px;
    backdrop-filter: blur(4px);
}

.dh-state-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
}

.dh-state-dot.speaking { background: #22c55e; animation: dhPulse 1.1s infinite; }
.dh-state-dot.thinking { background: #f59e0b; animation: dhPulse 1.4s infinite; }
.dh-state-dot.listening { background: #3b82f6; animation: dhPulse 1.6s infinite; }

@keyframes dhPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .45; transform: scale(.82); }
}

.dh-caption {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 14px;
}

.dh-caption-text {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 9px;
    background: rgba(15, 23, 42, .74);
    color: #fff;
    font-size: 14px;
    line-height: 1.55;
    min-height: 20px;
    max-width: 100%;
}

.dh-caption-text:empty { display: none; }

.dh-caption-bar {
    height: 3px;
    margin-top: 7px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .28);
    overflow: hidden;
}

.dh-caption-bar i {
    display: block;
    height: 100%;
    width: 0;
    background: #60a5fa;
    transition: width .12s linear;
}

.dh-transport {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.dh-transport .primary { min-width: 118px; }

.dh-now {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    align-self: center;
}

/* ---------- 逐句时间轴 ---------- */

.dh-timeline {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 208px;
    overflow-y: auto;
    padding-right: 2px;
}

.dh-line {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fcfdff;
    font-size: 13px;
    line-height: 1.5;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: border-color .12s, background .12s;
}

.dh-line:hover { border-color: #bfd4f5; background: #f8fbff; }

.dh-line.active {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .12);
}

.dh-line-idx {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e5edf9;
    color: #2563eb;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dh-line-body { min-width: 0; flex: 1; }

.dh-line-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* ---------- 右侧属性 ---------- */

.dh-field { margin-bottom: 12px; }
.dh-field > label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.dh-panel textarea { min-height: 148px; font-size: 13px; line-height: 1.6; }

.dh-count {
    font-size: 11px;
    color: var(--muted);
    text-align: right;
    margin-top: 3px;
}

.dh-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.dh-slider { width: 100%; accent-color: var(--primary); }

.dh-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.dh-chip {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

.dh-chip:hover { border-color: #bfd4f5; }

.dh-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.dh-hint {
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.55;
    margin-top: 6px;
}

.dh-divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

.dh-block-btn {
    width: 100%;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    color: #fff;
    box-shadow: 0 6px 16px rgba(59, 130, 246, .28);
}

.dh-block-btn:disabled { opacity: .65; cursor: default; box-shadow: none; }

/* ---------- 合规 ---------- */

.dh-compliance { margin-top: 10px; }

.dh-issue {
    display: flex;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 6px;
}

.dh-issue.block { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.dh-issue.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.dh-issue.pass { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

.dh-issue-word {
    font-weight: 700;
    flex: 0 0 auto;
}

/* ---------- 直播 ---------- */

.dh-danmaku {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.dh-dm {
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.5;
}

.dh-dm.me { background: #eff6ff; border-color: #bfdbfe; }
.dh-dm.user { background: #ecfdf5; border-color: #bbf7d0; }

.dh-dm-q { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

.dh-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.dh-product-card {
    border: 1px dashed #c7d6ec;
    border-radius: 11px;
    padding: 12px;
    background: #f8fbff;
}

.dh-product-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.dh-product-points {
    font-size: 12px;
    color: #475569;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ---------- 配置 / 素材 ---------- */

.dh-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
}

.dh-config-grid .dh-field.full { grid-column: 1 / -1; }

.dh-key-state {
    font-size: 11px;
    color: #15803d;
    margin-left: 4px;
}

.dh-note {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.65;
}

.dh-checklist { display: flex; flex-direction: column; gap: 7px; }

.dh-check {
    display: flex;
    gap: 8px;
    font-size: 12.5px;
    line-height: 1.55;
}

.dh-check b { color: #334155; flex: 0 0 auto; }

.dh-prompt-out textarea {
    min-height: 168px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.dh-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.dh-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
}

.dh-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59, 130, 246, .12); }

.dh-card-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }

.dh-card .dh-thumb-art { width: 52px; height: 52px; }

.dh-card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.dh-upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.dh-empty {
    padding: 26px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    border: 1px dashed var(--border);
    border-radius: 11px;
    background: #fbfcfe;
}

@media (max-width: 1240px) {
    .dh-studio,
    .dh-live { grid-template-columns: 1fr; }
    .dh-rail { order: 2; }
    .dh-panel { order: 3; }
    .dh-avatars { flex-direction: row; flex-wrap: wrap; }
    .dh-avatar-card { width: calc(50% - 4px); }
}

@media (max-width: 760px) {
    .dh-config-grid { grid-template-columns: 1fr; }
    .dh-caption-text { font-size: 13px; }
}

/* ---------- 弹幕接入示例 / 观测面板 ---------- */

.dh-code {
    margin: 10px 0 0;
    padding: 12px 14px;
    background: #0f172a;
    color: #d7e3f4;
    border-radius: 10px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
}

.dh-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 10px;
    margin: 10px 0 12px;
}

.dh-metric {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #fbfdff, #f4f8fd);
    text-align: center;
}

.dh-metric b {
    display: block;
    font-size: 17px;
    color: #1d4ed8;
    line-height: 1.3;
}

.dh-metric span {
    font-size: 11px;
    color: var(--muted);
}

.dh-kind {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 6px;
    background: #e5edf9;
    color: #2563eb;
    font-size: 10px;
    line-height: 1.6;
    letter-spacing: .02em;
}

/* ---------- 真人值守 / 收敛提示 ---------- */

.dh-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 12.5px;
    line-height: 1.55;
}

.dh-banner.warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.dh-banner button {
    padding: 4px 10px;
    font-size: 12px;
    margin-left: auto;
}

/* ---------- 真人素材：照片口型合成 / 视频循环 ---------- */

.dh-photo-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.dh-video-mode {
    position: relative;
    overflow: hidden;
    background: #0b1220;
}

.dh-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .8s ease;
}

.dh-video-mode.is-speaking .dh-video {
    transform: scale(1.015);
}

/* 形象卡里的真人缩略 */
.dh-thumb-art img,
.dh-thumb-art video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
