/* ========== 素材库模块样式 ========== */

.matx-host {
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 480px;
}

.matx-root {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* ---------- 顶部工具条：范围切换 + 搜索/刷新/新增 ---------- */
.matx-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* 范围切换（漫画/漫剧/剧本）：复用全局 sub-tabs/sub-tab 盒子样式，仅收紧下边距 */
.matx-topbar .sub-tabs {
    margin-bottom: 0;
}

.matx-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.matx-search {
    width: 300px;
    height: 32px;
}

/* ---------- 分类筛选行（胶囊按钮，无容器） ---------- */
.matx-chipbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* 分类筛选按钮：纯文字样式（无底色无描边），选中白色放大，未选中灰色 */
.matx-chip {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 1px 6px 0;
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    color: #808080;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.matx-chip:hover {
    color: #b8bcc0;
}

.matx-chip.active,
.matx-chip.active:hover {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}

.matx-typechip.active,
.matx-typechip.active:hover {
    color: #fff;
}

.matx-chip-danger { color: #ef6f78; }

/* ---------- 主体：左列表 + 右详情（同一面板，分隔线） ---------- */
.matx-main {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 0;
    background: #1d1f22;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

/* ---------- 左列表 ---------- */
.matx-list {
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.matx-item {
    padding: 10px 12px;
    background: #17181a;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.matx-item:hover {
    border-color: rgba(18, 199, 195, 0.35);
}

.matx-item.active {
    background: #17262a;
    border-color: #12c7c3;
}

.matx-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.matx-badge-official {
    padding: 2px 8px;
    font-size: 11px;
    color: #12c7c3;
    background: rgba(18, 199, 195, 0.12);
    border: 1px solid rgba(18, 199, 195, 0.35);
    border-radius: 999px;
    flex-shrink: 0;
}

/* 特邀私有卡标签：橙色，与官方青色区分 */
.matx-badge-private {
    padding: 2px 8px;
    font-size: 11px;
    color: #f0a35e;
    background: rgba(240, 163, 94, 0.12);
    border: 1px solid rgba(240, 163, 94, 0.35);
    border-radius: 999px;
    flex-shrink: 0;
}

/* 已下架标签：灰色，列表与详情通用 */
.matx-badge-disabled {
    padding: 2px 8px;
    font-size: 11px;
    color: #9aa0a6;
    background: rgba(154, 160, 166, 0.12);
    border: 1px solid rgba(154, 160, 166, 0.4);
    border-radius: 999px;
    flex-shrink: 0;
}

/* 已下架卡片整体降透明度（配合后端排序沉底） */
.matx-item--disabled {
    opacity: 0.55;
}
.matx-item--disabled .matx-item-name {
    color: #8a8f94;
}

.matx-item-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: #e8eaec;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matx-usage-tag {
    padding: 1px 8px;
    font-size: 11px;
    border: 1px solid;
    border-radius: 999px;
    flex-shrink: 0;
}

.matx-item-desc {
    font-size: 12px;
    line-height: 1.5;
    color: #8a8f94;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matx-dim { color: #6b7075; }

.matx-empty {
    padding: 40px 12px;
    text-align: center;
    color: #6b7075;
    font-size: 13px;
}

.matx-hint-danger { color: #ef6f78; }

.matx-page-navigator {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0 2px;
}

/* ---------- 右详情 ---------- */
.matx-detail {
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.matx-detail > .matxd-content,
.matx-detail > .matxd-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 140px;
}

.matx-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #8a8f94;
    font-size: 14px;
}

.matx-detail-empty-icon {
    font-size: 28px;
    color: #3a3e42;
}

.matxd-toprow {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.matxd-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.matxd-inline > label {
    font-size: 13px;
    color: #a9adb2;
    white-space: nowrap;
}

.matxd-inline .form-input {
    width: 180px;
    height: 30px;
    padding: 4px 10px;
    font-size: 13px;
}

.matxd-inline select.form-input {
    width: 140px;
    height: 30px;
}

.matxd-time {
    margin-left: auto;
    font-size: 12px;
    color: #6b7075;
}

.matx-usage-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.matx-pill {
    padding: 4px 14px;
    font-size: 12px;
    color: #b8bcc0;
    background: #17181a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}

.matx-pill:hover {
    color: #e8eaec;
    border-color: rgba(18, 199, 195, 0.45);
}

.matx-pill.active {
    color: #fff;
    background: var(--pill, #12c7c3);
    border-color: var(--pill, #12c7c3);
    font-weight: 600;
}

.matxd-content {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    background: #17181a;
}

.matxd-content-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.matxd-content-head label {
    font-size: 13px;
    color: #a9adb2;
}

.matxd-count {
    font-size: 12px;
    color: #6b7075;
    font-variant-numeric: tabular-nums;
}

.matx-textarea {
    flex: 1;
    min-height: 0;
    resize: none;
    line-height: 1.7;
    background: #111213;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: inherit;
}

.matx-textarea:focus,
.matx-textarea:focus-visible {
    border-color: rgba(255, 255, 255, 0.14) !important;
    background: #111213 !important;
    box-shadow: none !important;
    outline: none;
}

.matx-textarea::-webkit-scrollbar-corner {
    background: transparent;
}

.matx-textarea::-webkit-resizer {
    background: transparent;
    border: none;
}

.matxd-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---------- 图片 ---------- */
.matxd-block {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    background: #17181a;
}

.matx-img-wrap {
    position: relative;
    display: inline-block;
}

.matx-img-wrap img {
    max-width: 220px;
    max-height: 140px;
    display: block;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.matx-img-del {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    padding: 0;
}

.matx-img-del:hover {
    background: #ef6f78;
    border-color: #ef6f78;
}

.matx-img-mask {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 8px;
    color: #12c7c3;
    font-size: 13px;
}

/* ---------- 卡片网格（风格库/资产库，对齐软件端卡片形态） ---------- */
.matx-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
    align-content: start;
    padding: 2px;
}

.matx-card {
    background: #1d1f22;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.matx-card:hover {
    border-color: rgba(18, 199, 195, 0.55);
    box-shadow: 0 0 0 1px rgba(18, 199, 195, 0.25), 0 10px 22px rgba(0, 0, 0, 0.25);
}

.matx-card.is-off .matx-card-img img {
    opacity: 0.45;
}

.matx-card-img {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #111213;
}

.matx-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.matx-card-noimg {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 40px;
    color: #3a3e42;
}

.matx-card .matx-badge-official,
.matx-card .matx-badge-private {
    position: absolute;
    top: 8px;
    left: 8px;
}

.matx-card-name {
    position: absolute;
    left: 8px;
    bottom: 8px;
    max-width: calc(100% - 16px);
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matx-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.matx-card:hover .matx-card-actions {
    opacity: 1;
}

.matx-card-btn {
    padding: 3px 10px;
    font-size: 11px;
    color: #e8eaec;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    cursor: pointer;
}

.matx-card-btn:hover {
    border-color: #12c7c3;
    color: #12c7c3;
}

.matx-card-btn.danger:hover {
    border-color: #ef6f78;
    color: #ef6f78;
}

.matx-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 11px;
    color: #6b7075;
}

.matx-card-meta .matx-status {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.matx-card-meta .matx-status.on { background: #4dcf83; }
.matx-card-meta .matx-status.off { background: #55595e; }

/* ---------- 编辑弹窗（宽版：左图右表单） ---------- */
.modal.matx-modal {
    width: 640px;
}

.modal:has(.matx-modal-body) {
    width: 640px;
}

.matx-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.matxm-imgrow {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.matxm-img-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.matxm-img-preview {
    flex-shrink: 0;
}

.matxm-img-main img {
    width: 200px;
    height: 150px;
    object-fit: cover;
}

.matxm-img-side {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.matxm-img-placeholder {
    width: 200px;
    height: 150px;
    display: grid;
    place-items: center;
    background: #111213;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #6b7075;
    font-size: 13px;
}

.matxm-fields {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 2px;
}

.matxm-fields .matxd-inline .form-input {
    width: 100%;
}

.matxm-fields .matxd-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.matx-form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
    .matx-host { height: auto; }
    .matx-main {
        grid-template-columns: 1fr;
    }
    .matx-list {
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .matx-textarea { min-height: 200px; }
}

/* 画布指令：动态标签管理（仅 stv_prompt 注入） */
.matx-chip--manage {
    padding-right: 2px;
}

.matx-chip-tools {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.matx-tool {
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    color: #808080;
    font-size: 10px;
    font-style: normal;
    line-height: 1;
}

.matx-tool:hover {
    color: #12c7c3;
    background: rgba(255, 255, 255, 0.08);
}

.matx-addtag {
    color: #12c7c3;
}

.matx-taginput {
    width: 90px;
    height: 24px;
    padding: 0 8px;
    border: 1px solid #12c7c3;
    border-radius: 999px;
    background: #161616;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 12px;
    text-align: center;
    outline: none;
    cursor: text;
}
