/* 创作台：整屏铺满，左右不留白 */

body.app {
    height: 100svh;
    overflow: hidden;
    display: flex;
}

/* ---------- 左侧导航 ---------- */

.rail {
    width: 218px;
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--bg-soft);
    border-right: 1px solid var(--line);
    padding: 16px 12px;
    gap: 6px;
}

.rail .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 16px;
}

.rail .brand-mark {
    width: 28px;
    height: 28px;
    flex: none;
    padding: 0;
    border-radius: 3px;
    border: 1px solid var(--accent-line);
    background: var(--accent-veil);
    display: grid;
    place-items: center;
    color: var(--accent);
    cursor: pointer;
    transition: transform .18s, background .18s;
}

.rail .brand-mark:hover {
    background: var(--accent-soft);
    transform: rotate(35deg);
}

.rail .brand-mark svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
}

.rail .brand b {
    font-size: 15px;
    letter-spacing: -.02em;
}

.rail .brand-text span {
    font-size: 9.5px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--text-faint);
    display: block;
    line-height: 1;
    margin-top: 3px;
}

.rail-new {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 13.5px;
    font-weight: 600;
    transition: filter .2s, transform .15s;
}

.rail-new:hover {
    background: var(--accent-light);
}

.rail-new:active {
    transform: scale(.97);
}

.rail-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rail-nav button {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 38px;
    padding: 0 12px;
    border-radius: 9px;
    font-size: 13.5px;
    color: var(--text-dim);
    transition: background .18s, color .18s;
}

.rail-nav button:hover {
    background: rgba(var(--tint-rgb), .05);
    color: var(--text);
}

.rail-nav button.on {
    background: var(--accent-soft);
    color: var(--accent-light);
    font-weight: 600;
}

.rail-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rail-foot a,
.rail-foot button {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    font-size: 12.5px;
    color: var(--text-faint);
    transition: background .18s, color .18s;
}

.rail-foot a:hover,
.rail-foot button:hover {
    background: rgba(var(--tint-rgb), .05);
    color: var(--text);
}

@media (max-width: 860px) {
    .rail {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 120;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-rail);
    }

    body.rail-open .rail {
        transform: none;
    }
}

/* ---------- 主区 ---------- */

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 54px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(var(--scrim-rgb), .78);
    backdrop-filter: blur(14px);
}

.topbar h1 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.topbar .spacer {
    margin-left: auto;
}

.topbar .rail-toggle {
    display: none;
}

@media (max-width: 860px) {
    .topbar .rail-toggle {
        display: grid;
    }
}

.balance-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 13px;
    border-radius: 999px;
    background: rgba(var(--tint-rgb), .05);
    border: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-dim);
    transition: border-color .2s, color .2s;
}

.balance-chip:hover {
    border-color: var(--line-strong);
    color: var(--text);
}

.balance-chip b {
    color: var(--ok);
    font-variant-numeric: tabular-nums;
}

.balance-chip.warn b {
    color: var(--warn);
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: var(--text-dim);
    border: 1px solid transparent;
    transition: background .18s, color .18s;
}

.icon-btn:hover {
    background: rgba(var(--tint-rgb), .07);
    color: var(--text);
}

.view {
    flex: 1;
    min-height: 0;
    display: none;
    flex-direction: column;
    position: relative;
}

.view.on {
    display: flex;
}

/* ---------- 结果流 ---------- */

.feed {
    flex: 1;
    overflow-y: auto;
    padding: 26px 20px 12px;
}

.feed-inner {
    display: flex;
    flex-direction: column;
    gap: 18px;
    /* 参考即梦：结果流也收在屏幕中间一条窄栏里，和下面的发送框对齐，不铺满全屏 */
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

.empty {
    height: 100%;
    display: grid;
    place-content: center;
    justify-items: center;
    text-align: center;
    gap: 10px;
    color: var(--text-faint);
    padding: 40px 20px;
}

.empty svg {
    width: 40px;
    height: 40px;
    opacity: .5;
}

.empty b {
    font-size: 16px;
    color: var(--text-dim);
    font-weight: 600;
}

.empty p {
    margin: 0;
    font-size: 13px;
    max-width: 42ch;
}

/* 单条任务卡片 */

.job {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    overflow: hidden;
}

.job-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
}

.job-head .txt {
    flex: 1;
    min-width: 0;
}

.job-head p,
.job-prompt {
    margin: 0;
    font-size: 13.5px;
    color: var(--text);
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}

.job.prompt-open .job-prompt {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
    white-space: pre-wrap;
}

.job-prompt-more {
    display: inline-block;
    margin-top: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent-deep);
    font-size: 12px;
    cursor: pointer;
}

.job-prompt-more:hover {
    text-decoration: underline;
}

.job-prompt-more[hidden] {
    display: none;
}

.job-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.tag {
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(var(--tint-rgb), .05);
    border: 1px solid var(--line);
    font-size: 11px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    flex: none;
}

.status.queued,
.status.running {
    background: var(--accent-soft);
    color: var(--accent-light);
}

.status.succeeded {
    background: rgba(127, 184, 134, .16);
    color: #b3d9b8;
}

.status.failed {
    background: rgba(217, 99, 95, .16);
    color: #f0b5b3;
}

.status.cancelled {
    background: rgba(var(--tint-rgb), .07);
    color: var(--text-faint);
}

.spin {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.6px solid currentColor;
    border-top-color: transparent;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.job-body {
    padding: 0 16px 16px;
}

.job-video {
    width: 100%;
    border-radius: var(--r-md);
    background: #000;
    border: 1px solid var(--line);
    max-height: 70vh;
}

.job-progress {
    height: 4px;
    border-radius: 3px;
    background: rgba(var(--tint-rgb), .07);
    overflow: hidden;
}

.job-progress i {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-deep), var(--accent-light));
    transition: width .5s ease;
}

.job-err {
    padding: 11px 13px;
    border-radius: var(--r-md);
    background: rgba(217, 99, 95, .1);
    border: 1px solid rgba(217, 99, 95, .3);
    color: #f0bdbb;
    font-size: 13px;
}

.job-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-faint);
}

.job-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* 画质增强靠卡片右边站，和左边那排常用操作分开 */
.job-right {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.job-hd-bar {
    margin-top: 12px;
}

.job-actions .btn:disabled {
    opacity: .5;
    cursor: default;
}

/* ---------- 输入区 ---------- */

/* 发送按钮独占的定位锚点，发送按钮本身位置不受“跳到最新”按钮显隐影响 */
.send-group {
    margin-left: auto;
    position: relative;
    display: flex;
    align-items: center;
}

/* “跳到最新”按钮：用绝对定位悬浮在发送按钮左边，脱离参数栏的排版流——
   不管显示还是隐藏，都不占 .controls 的宽度，不会撑爆换行，也不会挪动发送按钮 */
.jump-latest {
    position: absolute;
    right: 44px;
    top: 50%;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--accent-line);
    background: var(--accent-veil);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) scale(.85);
    transition: opacity .15s ease, transform .15s ease;
}

.jump-latest.on {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) scale(1);
}

.jump-latest:hover {
    background: var(--accent-soft);
}

.jump-latest svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
}

.composer-zone {
    flex: none;
    padding: 8px 20px 20px;
}

/* 参考即梦：发送框不铺满，收在屏幕中间一条窄栏里，看起来更轻 */
.composer {
    max-width: 640px;
    margin: 0 auto;
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    box-shadow: var(--shadow-composer);
    transition: border-color .2s, max-width .25s ease, opacity .2s ease;
}

.composer.drop {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 参考素材托盘 */

.refs {
    display: flex;
    gap: 10px;
    padding: 14px 14px 4px;
    overflow-x: auto;
    align-items: flex-start;
}

.refs:empty {
    display: none;
}

.ref {
    position: relative;
    width: 76px;
    flex: none;
}

.ref-thumb {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--line-strong);
    background: var(--surface-3);
    display: grid;
    place-items: center;
    color: var(--text-faint);
}

.ref-thumb img,
.ref-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ref-label {
    max-width: 76px;
    margin-top: 5px;
    font-size: 10.5px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 颜色由 .tok-image / .tok-audio 给，和提示词里的标签保持一致 */
    background: none;
}

.ref-x {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    color: var(--text-dim);
}

.ref-x:hover {
    background: var(--err);
    color: #fff;
    border-color: transparent;
}

.ref-wait {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(10, 10, 10, .58);
    color: var(--accent);
}

/* 缩略图可点：点一下把「图片1」写进提示词 */
.ref-thumb[data-insert] {
    cursor: pointer;
}

.ref-put {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    background: rgba(10, 10, 10, .68);
    opacity: 0;
    transition: opacity .15s ease;
}

.ref-thumb[data-insert]:hover .ref-put {
    opacity: 1;
}

.ref-thumb[data-insert]:active .ref-put {
    background: color-mix(in srgb, var(--accent) 40%, rgba(10, 10, 10, .68));
}

/* 音色参考的句式提醒，跟在参考素材后面占满一行 */
.ref-tips {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 14px 0;
}

.ref-tips:empty {
    display: none;
}

.ref-tip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-dim);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
    border-radius: var(--r-sm);
}

/* 音色这条不照做就白花钱，给它更强的存在感 */
.ref-tip-warn {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border-color: color-mix(in srgb, var(--accent) 42%, transparent);
    color: var(--text);
}

.ref-tip svg {
    flex: none;
    margin-top: 3px;
    color: var(--accent);
}

.ref-tip b {
    color: var(--accent);
}

.ref-tip button {
    flex: none;
    align-self: center;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text);
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
}

.ref-tip button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.ref-role {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .6);
    font-size: 9.5px;
    color: #fff;
    backdrop-filter: blur(4px);
}

.ref-add {
    width: 76px;
    height: 76px;
    border-radius: var(--r-md);
    border: 1px dashed var(--line-strong);
    display: grid;
    place-items: center;
    gap: 3px;
    color: var(--text-faint);
    flex: none;
    font-size: 10.5px;
    transition: border-color .2s, color .2s;
}

.ref-add:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

.prompt-wrap {
    padding: 4px 16px 0;
    position: relative;
}

/* 输入 @ 时从资产库挑素材 */

.mention {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 12px;
    width: min(360px, calc(100% - 24px));
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
    border-radius: var(--r-md);
    background: var(--pop);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-pop);
    backdrop-filter: blur(18px);
    z-index: 70;
    display: none;
}

.mention.on {
    display: block;
}

.mention-title {
    padding: 7px 10px 5px;
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.mention button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--text-dim);
    text-align: left;
    transition: background .15s, color .15s;
}

.mention button:hover,
.mention button.on {
    background: var(--accent-soft);
    color: var(--accent-light);
}

.mention-thumb {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface-3);
    display: grid;
    place-items: center;
    color: var(--text-faint);
}

.mention-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mention-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mention-kind {
    font-size: 11px;
    color: var(--text-faint);
    flex: none;
}

/* 输入框和它底下那层着色文本必须逐像素对齐，字体相关的值都写在一处 */
textarea#prompt,
.prompt-hl {
    font: inherit;
    font-size: 14.5px;
    line-height: 1.65;
    letter-spacing: normal;
    padding: 10px 0;
    border: none;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
}

textarea#prompt {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 44px;
    max-height: 220px;
    resize: none;
    overflow-y: auto;
    background: none;
    outline: none;
    /* 字交给底下那层画，这里只留光标 */
    color: transparent;
    caret-color: var(--text);
}


/* 贴着 .prompt-wrap 的内边距铺开，正好盖住 textarea 的位置 */
.prompt-hl {
    position: absolute;
    top: 4px;
    bottom: 0;
    left: 16px;
    right: 16px;
    overflow: hidden;
    color: var(--text);
    pointer-events: none;
}

/* 素材名做成彩色标签：图片偏蓝，音频偏绿，一眼分得开。
   这一层要和输入框逐字对齐，所以绝不能动 padding、margin、字重、字号——
   任何改变字宽的属性都会让标签后面的光标跑偏。底色用 box-shadow 撑出来，它不占布局。 */
.tok {
    border-radius: 3px;
}

.tok-image {
    color: #8cc0ff;
    background: rgba(64, 132, 232, .2);
    box-shadow: 0 0 0 2px rgba(64, 132, 232, .2);
}

.tok-audio {
    color: #74dba2;
    background: rgba(52, 178, 118, .2);
    box-shadow: 0 0 0 2px rgba(52, 178, 118, .2);
}

.tok-video {
    color: #d7a6ff;
    background: rgba(160, 96, 224, .2);
    box-shadow: 0 0 0 2px rgba(160, 96, 224, .2);
}

/* 卡片和候选里的名字不用跟输入框对齐，正常留白就行 */
.mention-kind.tok-image,
.mention-kind.tok-audio {
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: none;
}

.ref-label.tok-image,
.ref-label.tok-audio,
.ref-label.tok-video {
    background: none;
    box-shadow: none;
}

/* 悬停某个素材名时浮出来的缩略图 */
.tok-peek {
    position: absolute;
    z-index: 80;
    width: 150px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    border-radius: var(--r-md);
    background: var(--pop);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-pop);
    pointer-events: none;
}

.tok-peek.on {
    display: flex;
}

.tok-peek img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: var(--r-sm);
    background: var(--surface-3);
}

.tok-peek-icon {
    height: 60px;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    color: var(--accent);
}

.tok-peek b {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tok-peek span {
    font-size: 11px;
    color: var(--text-dim);
}

textarea#prompt::placeholder {
    color: var(--text-faint);
}

/* 参数栏 */

.controls {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 10px;
    flex-wrap: wrap;
}

.ctl {
    position: relative;
}

.ctl-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(var(--tint-rgb), .05);
    border: 1px solid var(--line);
    font-size: 11.5px;
    color: var(--text-dim);
    white-space: nowrap;
    transition: background .18s, border-color .18s, color .18s;
}

.ctl-btn:hover,
.ctl.open .ctl-btn {
    background: rgba(var(--tint-rgb), .09);
    border-color: var(--line-strong);
    color: var(--text);
}

.ctl-btn b {
    color: var(--text);
    font-weight: 600;
}

.ctl-btn.accent {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-light);
}

.ctl-btn.accent b {
    color: var(--accent-light);
}

.ctl-btn.on {
    background: rgba(127, 184, 134, .13);
    border-color: rgba(127, 184, 134, .38);
    color: #b3d9b8;
}

.ctl-btn .chev {
    opacity: .6;
    width: 13px;
    height: 13px;
}

.menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 210px;
    max-height: 340px;
    overflow-y: auto;
    padding: 6px;
    border-radius: var(--r-md);
    background: var(--pop);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-pop);
    backdrop-filter: blur(18px);
    z-index: 60;
    display: none;
}

.ctl.open .menu {
    display: block;
}

.menu.right {
    left: auto;
    right: 0;
}

.menu-title {
    padding: 7px 10px 5px;
    font-size: 10.5px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 9px;
    font-size: 13px;
    color: var(--text-dim);
    text-align: left;
    transition: background .15s, color .15s;
}

.menu button:hover {
    background: rgba(var(--tint-rgb), .07);
    color: var(--text);
}

.menu button.on {
    background: var(--accent-soft);
    color: var(--accent-light);
}

.menu button .tick {
    margin-left: auto;
    color: var(--accent);
    opacity: 0;
}

.menu button.on .tick {
    opacity: 1;
}

.menu button small {
    display: block;
    font-size: 11px;
    color: var(--text-faint);
    font-weight: 400;
}

.menu-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-dim);
}

.menu-row input[type="number"],
.menu-row input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    background: var(--sunken);
    border: 1px solid var(--line);
    outline: none;
}

.menu-row input:focus {
    border-color: var(--accent);
}

.ratio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 4px;
}

.ratio-grid button {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 4px;
    text-align: center;
    font-size: 12px;
}

.ratio-box {
    border: 1.6px solid currentColor;
    border-radius: 3px;
    opacity: .65;
}

.send {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: var(--on-accent);
    transition: background .2s, transform .15s, opacity .2s;
}

.send:hover:not(:disabled) {
    background: var(--accent-light);
}

.send:active:not(:disabled) {
    transform: scale(.94);
}

.send:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.composer-hint {
    padding: 0 18px 12px;
    font-size: 11.5px;
    color: var(--text-faint);
}

/* ---------- 资产库 / 任务 ---------- */

.panel {
    flex: 1;
    overflow-y: auto;
    padding: 26px 26px 40px;
}

.panel-head {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.panel-head h2 {
    margin: 0;
    font-size: 27px;
    letter-spacing: -.03em;
    font-weight: 800;
}

.panel-head p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--text-faint);
}

.filters {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}

/* 弹窗里的一排选项：和筛选条同样的胶囊，但不靠右 */
.chips-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    height: 30px;
    padding: 0 13px;
    border-radius: 999px;
    background: rgba(var(--tint-rgb), .05);
    border: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-dim);
    transition: background .18s, color .18s;
}

.chip:hover {
    background: rgba(var(--tint-rgb), .09);
    color: var(--text);
}

.chip.on {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-light);
    font-weight: 600;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 14px;
}

.tile {
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
    transition: border-color .2s, transform .2s;
}

.tile:hover {
    border-color: var(--line-strong);
    transform: translateY(-2px);
}

.tile-media {
    position: relative;
    aspect-ratio: 16 / 10;
    background: #0a0a0a;
    display: grid;
    place-items: center;
    color: var(--text-faint);
    cursor: pointer;
}

.tile-media img,
.tile-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- 多选与框选 ---------- */

.tile-tick {
    position: absolute;
    top: 8px;
    right: 8px;
    /* 左上角让给「上传/生成」那个角标 */
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    border: 1.5px solid rgba(255, 255, 255, .45);
    background: rgba(10, 10, 10, .55);
    color: transparent;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, background .15s ease, color .15s ease;
}

.tile:hover .tile-tick,
.tile.is-picked .tile-tick {
    opacity: 1;
}

.tile-tick.on {
    background: var(--accent);
    border-color: var(--accent);
    /* 跟主题走：深色是金底深色钩，浅色是墨底白钩，别写死深色 */
    color: var(--on-accent);
}

.tile.is-picked {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.pick-bar {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.pick-bar.on {
    display: flex;
}

.pick-bar b {
    margin-right: auto;
    font-size: 13px;
}

/* 拉框时别把卡片文字选成一片蓝 */
body.is-marquee {
    user-select: none;
}

.marquee {
    position: fixed;
    z-index: 60;
    pointer-events: none;
    border: 1px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    border-radius: 4px;
}

/* 音频没有画面，卡片上直接给一个能试听的播放器 */
.tile-audio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 100%;
    padding: 0 12px;
    color: var(--accent);
}

.tile-audio audio {
    width: 100%;
    height: 32px;
    cursor: default;
}

.tile-kind {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .58);
    font-size: 10px;
    color: #fff;
    backdrop-filter: blur(4px);
}

/* 已进虚拟人像库的角标。放右下角：右上是勾选框，左上是来源标，都占着 */
.tile-avatar {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    color: #fff;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(4px);
}

.tile-avatar.on {
    background: var(--accent);
    color: var(--on-accent, #fff);
}

.tile-avatar.wait {
    background: rgba(0, 0, 0, .58);
}

.tile-avatar.wait .icon {
    animation: spin 1.4s linear infinite;
}

/* 卡片右键菜单 */
.ctxmenu {
    position: fixed;
    z-index: 90;
    display: none;
    min-width: 178px;
    padding: 6px;
    background: var(--pop, var(--surface-2));
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, .35));
}

.ctxmenu.on {
    display: block;
}

.ctxmenu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.ctxmenu button:hover:not(:disabled) {
    background: var(--surface-3, var(--sunken));
}

.ctxmenu button:disabled {
    color: var(--muted);
    cursor: default;
}

.ctxmenu button.danger {
    color: #e79a97;
}

/* 入库进度：贴在页面顶端，批量传的时候一条条往下滚 */
.job-bar {
    position: fixed;
    z-index: 88;
    top: 14px;
    left: 50%;
    transform: translate(-50%, -140%);
    width: min(460px, calc(100vw - 32px));
    padding: 12px 14px;
    background: var(--pop, var(--surface-2));
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, .35));
    opacity: 0;
    transition: transform .28s cubic-bezier(.2, .9, .3, 1), opacity .28s;
    pointer-events: none;
}

.job-bar.on {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.job-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.job-head b {
    margin-right: auto;
}

.job-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.job-x {
    display: inline-flex;
    padding: 2px;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

.job-log {
    max-height: 132px;
    margin-top: 8px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.7;
    color: var(--muted);
}

.job-line.ok {
    color: var(--text);
}

.job-line.err {
    color: #e79a97;
}

/* 上传中的占位卡片 */

.tile.is-pending {
    border-style: dashed;
}

.tile.is-pending .tile-media {
    cursor: default;
}

.tile.is-pending .tile-media img,
.tile.is-pending .tile-media svg {
    opacity: .45;
}

.tile-prog {
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    background: rgba(var(--tint-rgb), .12);
}

.tile-prog i {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width .2s ease;
}

.tile-info {
    padding: 10px 11px;
}

.tile-info b {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-info span {
    font-size: 11px;
    color: var(--text-faint);
}

.tile-ops {
    display: flex;
    gap: 4px;
    padding: 0 8px 9px;
}

.tile-ops button {
    flex: 1;
    height: 28px;
    border-radius: 7px;
    font-size: 11.5px;
    color: var(--text-dim);
    background: rgba(var(--tint-rgb), .05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background .18s, color .18s;
}

.tile-ops button:hover {
    background: rgba(var(--tint-rgb), .1);
    color: var(--text);
}

.tile-ops button.danger:hover {
    background: rgba(217, 99, 95, .18);
    color: #f0b5b3;
}

/* ---------- 弹窗 ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: none;
    place-items: center;
    padding: 24px;
    background: var(--veil);
    backdrop-filter: blur(8px);
}

.modal.on {
    display: grid;
}

.sheet {
    width: min(480px, 100%);
    max-height: 86vh;
    overflow-y: auto;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-sheet);
    padding: 24px;
}

.sheet.wide {
    width: min(900px, 100%);
    padding: 0;
    background: #000;
}

.settings-sheet {
    width: min(720px, 100%);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.settings-card {
    padding: 14px 16px 16px;
    border-radius: var(--r-md);
    background: var(--sunken);
    border: 1px solid var(--line);
    min-width: 0;
}

.settings-card > label {
    display: block;
    font-size: 12px;
    letter-spacing: .04em;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.settings-card .row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.settings-card input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 13px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    outline: none;
    font-size: 13.5px;
}

.settings-card input:focus {
    border-color: var(--accent);
}

.settings-sheet .btn {
    width: auto;
}

.settings-sheet .row .btn {
    flex: none;
}

.settings-card .hint {
    margin-top: 8px;
}

.settings-card .balance-box {
    margin-top: 10px;
}

.settings-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 10px;
    font-size: 12px;
}

.settings-links a {
    color: var(--text-faint);
}

.settings-links a:hover {
    color: var(--accent);
}

@media (max-width: 640px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.sheet-head {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
}

.sheet-head h3 {
    margin: 0;
    font-size: 17px;
    letter-spacing: -.02em;
}

.sheet-head button {
    margin-left: auto;
    color: var(--text-faint);
}

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 7px;
}

.field .row {
    display: flex;
    gap: 8px;
}

.field input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 13px;
    border-radius: 10px;
    background: var(--sunken);
    border: 1px solid var(--line);
    outline: none;
    font-size: 13.5px;
}

.field input:focus {
    border-color: var(--accent);
}

.hint {
    font-size: 12px;
    color: var(--text-faint);
    margin: 8px 0 0;
    line-height: 1.6;
}

.balance-box {
    margin-top: 4px;
    padding: 14px;
    border-radius: var(--r-md);
    background: rgba(var(--tint-rgb), .04);
    border: 1px solid var(--line);
    font-size: 13px;
}

.balance-box .big {
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ok);
    font-variant-numeric: tabular-nums;
}

.balance-box .sub {
    color: var(--text-faint);
    font-size: 12px;
    margin-top: 3px;
}

.usage-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(var(--tint-rgb), .08);
    overflow: hidden;
    margin-top: 12px;
}

.usage-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-deep), var(--accent-light));
}

.sheet .pick-bar {
    margin: 0 0 14px;
}

.sheet .pick-bar.on {
    display: flex;
}

.modal .tile-tick {
    /* 弹窗里就是来勾选的，不需要悬停才露出来 */
    opacity: 1;
}

.sheet .btn {
    width: 100%;
}

.sheet .pick-bar .btn {
    width: auto;
    flex: none;
}

.sheet .field .row .btn {
    flex: 1;
    width: auto;
    min-width: 0;   /* 文案长的时候允许压缩，别把面板撑破 */
}

.btn-ghost.danger {
    color: #e79a97;
    border-color: rgba(217, 99, 95, .35);
}

.btn-ghost.danger:hover:not(:disabled) {
    background: rgba(217, 99, 95, .12);
    border-color: rgba(217, 99, 95, .55);
}

.sheet-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    font-size: 12.5px;
}

.sheet-links a,
.sheet-links button {
    color: var(--text-faint);
}

.sheet-links a:hover {
    color: var(--accent);
}

.sheet-links button:hover {
    color: var(--err);
}

#viewer video,
#viewer img {
    width: 100%;
    max-height: 82vh;
    object-fit: contain;
    background: #000;
    border-radius: var(--r-lg);
}

#viewer audio {
    width: 100%;
}

/* 大图预览里放音频，光一条播放条会像块黑板，补上名字和大小才认得出 */
.audio-player {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 40px 30px 34px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    text-align: center;
}

.audio-player svg {
    color: var(--accent);
}

.audio-player b {
    font-size: 15px;
    word-break: break-all;
}

.audio-player span {
    font-size: 12px;
    color: var(--text-faint);
}

.audio-player audio {
    margin-top: 10px;
}
