/* 千问工作台 QWEN WORKBENCH:深色专业创作工作台
   设计令牌:配色 / 圆角 / 间距 / 字号统一从此处引用 */
:root {
    /* 配色:石墨蓝黑底 + 青蓝主色,面向创作工具的中性专业风 */
    --bg: #0b0e14;            /* 页面底:更深的石墨蓝黑 */
    --bg-soft: #11141c;       /* 顶栏/嵌入面板 */
    --bg-card: #161a24;       /* 卡片/侧栏 */
    --bg-input: #0d1017;      /* 输入控件:比卡片再深一档 */
    --border: #262c3a;
    --border-strong: #333b4f;
    --text: #e6e9f2;
    --text-dim: #8b93a7;
    --accent: #4f8cff;        /* 主色:克制的青蓝 */
    --accent-strong: #2f6fef;
    --accent-soft: rgba(79, 140, 255, 0.14);
    --accent-glow: rgba(79, 140, 255, 0.35);
    --ok: #3ecf8e;
    --err: #f26d6d;
    --warn: #e8b64c;

    /* 圆角令牌:控件 8 / 卡片 12 / 弹窗 14 / 圆形 999 */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 14px;
    --r-full: 999px;

    /* 间距令牌:4 的倍数 */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;

    /* 字号令牌 */
    --fs-xs: .75rem;
    --fs-sm: .82rem;
    --fs-base: .9rem;
    --fs-md: .95rem;
    --fs-lg: 1.05rem;

    /* 阴影令牌 */
    --shadow-pop: 0 16px 48px rgba(0, 0, 0, .5);
    --shadow-card: 0 2px 10px rgba(0, 0, 0, .25);

    font-size: 15px;
}
* { box-sizing: border-box; }
/* 关键:恢复 hidden 属性的默认行为(否则 .modal/.lightbox 的 display:flex 会覆盖它,弹窗全屏叠加导致黑屏) */
[hidden] { display: none !important; }
body {
    margin: 0;
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(79, 140, 255, .07), transparent 60%),
        radial-gradient(900px 420px at -10% 110%, rgba(79, 140, 255, .05), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-base); margin: 14px 0 8px; color: var(--text-dim); }
.muted { color: var(--text-dim); font-size: var(--fs-sm); font-style: normal; }
.empty-hint { padding: 18px 0; text-align: center; }

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-card {
    width: 380px; padding: 40px 36px;
    background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
}
.login-logo { display: flex; align-items: center; gap: var(--sp-2); }
.login-logo h1 { font-size: 1.3rem; letter-spacing: 1px; }
.logo-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6fd3f7);
    box-shadow: 0 0 12px var(--accent-glow);
}
.login-sub { color: var(--text-dim); margin: 8px 0 26px; font-size: var(--fs-sm); letter-spacing: .5px; }

/* ---------- 顶栏 ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border);
    background: rgba(17, 20, 28, .85); backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: var(--sp-2); letter-spacing: .5px; }
.brand em {
    color: var(--text-dim); font-style: normal; font-size: var(--fs-xs);
    font-weight: 400; letter-spacing: 1.5px; text-transform: uppercase;
    border: 1px solid var(--border-strong); border-radius: var(--r-full);
    padding: 2px 8px; margin-left: 2px;
}
.topbar-right { display: flex; align-items: center; gap: var(--sp-2); }
.badge {
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--accent-glow); border-radius: var(--r-full);
    padding: 3px 12px; font-size: var(--fs-sm);
}
.badge b { font-size: var(--fs-base); }

.warn-banner {
    background: rgba(232, 182, 76, .08); color: var(--warn);
    border-bottom: 1px solid rgba(232, 182, 76, .25);
    padding: var(--sp-3) var(--sp-5); font-size: var(--fs-base);
    display: flex; align-items: center; gap: var(--sp-3);
}

/* ---------- 布局 ---------- */
.layout { display: flex; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); align-items: flex-start; }
.workbench {
    width: 400px; flex-shrink: 0; position: sticky; top: 76px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: var(--sp-4); max-height: calc(100vh - 96px); overflow-y: auto;
    box-shadow: var(--shadow-card);
}
.content { flex: 1; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------- 模式切换 ---------- */
.mode-tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-1);
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 5px; margin-bottom: 14px;
}
.mode-tab {
    border: 0; background: transparent; color: var(--text-dim);
    padding: 8px 0; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-base);
    transition: color .15s, background .15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: var(--fs-sm); margin-bottom: 6px; color: var(--text-dim); }
.field-disabled { opacity: .45; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
    width: 100%; padding: 9px var(--sp-3);
    background: var(--bg-input); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    font: inherit; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

.prompt-tools { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.form-error {
    background: rgba(242, 109, 109, .1); border: 1px solid rgba(242, 109, 109, .35);
    color: #ff9e9e; border-radius: var(--r-sm); padding: 8px 12px; font-size: var(--fs-sm); margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.switch-list { border-top: 1px solid var(--border); padding-top: 10px; margin-bottom: 14px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: var(--fs-base); color: var(--text-dim); }
.switch-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- 按钮 ---------- */
.btn {
    border: 1px solid var(--border-strong); background: var(--bg-soft); color: var(--text);
    border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-4); cursor: pointer;
    font: inherit; font-size: var(--fs-base);
    transition: border-color .15s, background .15s, transform .06s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    border-color: var(--accent-strong); color: #fff; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.12); border-color: var(--accent-strong); }
.btn-danger { color: #ff9e9e; border-color: rgba(242, 109, 109, .4); }
.btn-danger:hover { border-color: var(--err); background: rgba(242, 109, 109, .08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: var(--fs-sm); }
.btn-lg { padding: 12px 0; font-size: 1rem; letter-spacing: 6px; }
.btn-block { width: 100%; }
.btn-close {
    border: 0; background: transparent; color: var(--text-dim); cursor: pointer;
    font-size: var(--fs-md); padding: 2px 6px; border-radius: var(--r-sm);
}
.btn-close:hover { color: var(--text); background: var(--bg-input); }

/* ---------- 参考图 ---------- */
.ref-drop {
    border: 1.5px dashed var(--border); border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4); text-align: center; cursor: pointer; margin-bottom: 12px;
    color: var(--text-dim); font-size: var(--fs-sm); transition: border-color .15s;
}
.ref-drop.drag, .ref-drop:hover { border-color: var(--accent); }
.ref-previews { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 10px; }
.ref-thumb { position: relative; width: 68px; height: 68px; }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-sm); }
.ref-del {
    position: absolute; top: -6px; right: -6px;
    background: var(--err); color: #fff; border: 0; border-radius: 50%;
    width: 18px; height: 18px; font-size: 10px; cursor: pointer; line-height: 1;
    z-index: 2; /* 悬浮角标置于图片之上,防止被兄弟元素遮挡 */
}

/* ---------- 提词器(以图生词) ---------- */
.reverse-block { border-top: 1px solid var(--border); padding-top: var(--sp-3); margin-bottom: var(--sp-4); }
.reverse-box { display: grid; gap: var(--sp-2); }
.reverse-upload {
    position: relative;
    border: 1.5px dashed var(--border); border-radius: var(--r-md);
    min-height: 72px; padding: var(--sp-2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-dim); font-size: var(--fs-sm);
    transition: border-color .15s, background .15s;
}
.reverse-upload:hover, .reverse-upload.drag { border-color: var(--accent); background: var(--accent-soft); }
.reverse-upload img {
    max-height: 140px; max-width: 100%; object-fit: contain; border-radius: var(--r-sm);
    display: block;
}
/* 扫光加载态:一道高光周期性从左扫到右(clip 限定在圆角内,不影响角标) */
.reverse-upload.scanning { pointer-events: none; border-color: var(--accent); }
.reverse-upload.scanning::before {
    content: ""; position: absolute; inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        100deg,
        transparent 20%,
        rgba(79, 140, 255, .12) 42%,
        rgba(255, 255, 255, .22) 50%,
        rgba(79, 140, 255, .12) 58%,
        transparent 80%
    );
    transform: translateX(-100%);
    animation: scan-sweep 1.2s ease-in-out infinite;
    pointer-events: none;
}
/* 删除角标:容器内右上角(容器无 overflow:hidden,也不会被页面边缘裁剪) */
.reverse-upload .reverse-del {
    position: absolute; top: 6px; right: 6px;
    background: var(--err); color: #fff; border: 0; border-radius: 50%;
    width: 20px; height: 20px; font-size: 11px; cursor: pointer; line-height: 1;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
@keyframes scan-sweep {
    to { transform: translateX(100%); }
}
.reverse-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- 任务卡片 ---------- */
.task-cards { display: grid; gap: var(--sp-2); }
.task-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
    box-shadow: var(--shadow-card);
}
.task-card-head { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); color: var(--text-dim); }
.task-card-status { display: flex; align-items: center; gap: var(--sp-2); margin: 8px 0; }
.task-card-imgs { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.task-card-imgs img { max-width: 180px; max-height: 180px; border-radius: var(--r-sm); cursor: zoom-in; }
.task-error {
    background: rgba(242,109,109,.08); color: #ff9e9e; border-radius: var(--r-sm);
    padding: 8px 10px; font-size: var(--fs-sm); margin: 6px 0; overflow-wrap: anywhere;
}

.tag { border-radius: var(--r-full); padding: 2px 10px; font-size: var(--fs-xs); }
.tag-ok { background: rgba(62,207,142,.12); color: var(--ok); }
.tag-err { background: rgba(242,109,109,.12); color: var(--err); }
.tag-run { background: var(--accent-soft); color: var(--accent); }

.spinner {
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--accent); border-top-color: transparent;
    display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 历史记录 ---------- */
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.filters input[type="search"] { width: 200px; }
.filters select { width: auto; }
.history-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-3);
}
.history-card {
    position: relative;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
    overflow: hidden; cursor: pointer; box-shadow: var(--shadow-card);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.history-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.sel-box {
    position: absolute; top: var(--sp-2); left: var(--sp-2); z-index: 3;
    background: rgba(11, 14, 20, .65); border-radius: var(--r-sm);
    padding: 3px; cursor: pointer; backdrop-filter: blur(2px);
}
.sel-box input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; display: block; }
.sel-bar {
    display: flex; align-items: center; gap: var(--sp-2);
    background: var(--accent-soft); border: 1px solid var(--accent-glow);
    border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-3); font-size: var(--fs-sm);
}
.sel-bar b { color: var(--accent); }
.history-card:hover {
    border-color: var(--accent); transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.history-thumb {
    aspect-ratio: 1; background: var(--bg-input);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-failed { color: var(--err); font-size: var(--fs-sm); }
.history-info { padding: var(--sp-3); display: grid; gap: var(--sp-1); }
.history-model { font-size: var(--fs-sm); }
.history-prompt { font-size: var(--fs-sm); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-date { font-size: var(--fs-xs); }
.history-foot { text-align: center; padding: 14px 0; }

/* ---------- 弹窗 ---------- */
.modal {
    position: fixed; inset: 0; background: rgba(4, 6, 11, .72);
    display: flex; align-items: center; justify-content: center; z-index: 50;
    backdrop-filter: blur(4px); padding: 20px;
}
.modal-box {
    background: var(--bg-soft); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
    width: 480px; max-height: 88vh; display: flex; flex-direction: column;
    box-shadow: var(--shadow-pop);
}
.modal-lg { width: 760px; }
.modal-sm { width: 380px; }
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: var(--sp-2); justify-content: flex-end; }

.settings-group-title { margin: 18px 0 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.settings-group-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.test-row { display: flex; align-items: center; gap: var(--sp-2); margin: 8px 0 4px; font-size: var(--fs-sm); }

/* ---------- 详情 ---------- */
.detail-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-2); margin-bottom: 10px; }
.detail-imgs img { width: 100%; border-radius: var(--r-sm); cursor: zoom-in; }
.detail-refs { display: flex; gap: var(--sp-2); margin: 8px 0; }
.detail-refs img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); cursor: zoom-in; }
.detail-params { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.kv {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r-sm);
    padding: 4px 10px; font-size: var(--fs-sm);
}
.kv b { color: var(--text-dim); font-weight: 400; margin-right: 6px; }
.detail-row { display: grid; grid-template-columns: 90px 1fr; gap: var(--sp-2); margin-bottom: 8px; font-size: var(--fs-sm); }
.detail-key { color: var(--text-dim); }

/* ---------- 灯箱 / 提示 ---------- */
.lightbox {
    position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 99;
    display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px;
}
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: var(--r-sm); }
.toast {
    position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
    background: var(--bg-card); border: 1px solid var(--ok); color: var(--text);
    padding: 10px 20px; border-radius: var(--r-full); font-size: var(--fs-base); z-index: 100;
    box-shadow: var(--shadow-pop); max-width: 80vw;
}
.toast-err { border-color: var(--err); }

/* ---------- 滚动条(WebKit) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong); border-radius: var(--r-full);
    border: 2px solid var(--bg-card);
}
::-webkit-scrollbar-thumb:hover { background: #46506a; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
    .layout { flex-direction: column; }
    .workbench { width: 100%; position: static; max-height: none; }
}
