/* 插件管理（配置台）：列表 + 详情 + 上传安装。
 * v4 视觉重做：渐变 hero、卡片选中态高亮条、状态徽标玻璃化、
 * 拖拽区动效、弹窗入场动画。类名与 plugin-manager.js / e2e 锁保持不变。
 */

.pm-wrap { max-width: 1240px; margin: 0 auto; padding: 18px 22px 48px; }
.pm-wrap > * { box-sizing: border-box; }

/* ---------------------------- 页面壳（plugins.html） ----------------------------
   这一页的 DOM 是 `.pm-content > .pm-intro / .pm-alert / .pm-drop / .pm-layout / .pm-actions`，
   4.32 补回：上一版样式按 `.pm-wrap / .pm-hero` 写，和页面标记对不上——列表被拉成
   整行、详情退化成一行行裸文字、弹窗没有卡片底。这里按实际标记定义，不再留第二套。 */
.pm-content {
  width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px 22px 48px;
  flex: 1; min-height: 0; overflow-y: auto;
}
html[data-embed="1"] .pm-content { padding: 14px 14px 30px; flex: none; overflow: visible; }

.pm-intro {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r);
  padding: 16px 20px; margin-bottom: 14px;
}
.pm-intro h2 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 7px; }
.pm-intro p { margin: 0; font-size: 12px; line-height: 1.75; color: var(--text2); max-width: 820px; }
.pm-intro p b { color: var(--text); font-weight: 600; }

.pm-note { font-size: 11.5px; line-height: 1.7; color: var(--text3); margin: 12px 0 0; }
.pm-note code {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px;
  background: var(--pill); border-radius: 5px; padding: 1px 5px;
}

/* 本机 ComfyUI 的引导条：地址配置已并进「设置 → ComfyUI」，这里只留一扇门。
   与 .pm-alert 区分开——这不是警告，是路标。 */
.pm-comfy-bridge {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--line2); border-left: 3px solid var(--tone-info, #5b8cff);
  background: var(--card2); border-radius: var(--r);
  padding: 12px 16px; margin-bottom: 14px;
}
.pm-comfy-bridge-text { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
.pm-comfy-bridge-text b { font-size: 12.5px; font-weight: 600; color: var(--text); }
.pm-comfy-bridge-text span { font-size: 11.5px; line-height: 1.65; color: var(--text2); }
@media (max-width: 760px) { .pm-comfy-bridge { flex-direction: column; align-items: stretch; } }

/* 上传区：标题 / 按钮 / 提示三行 */
.pm-drop-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.pm-drop-hint { font-size: 11.5px; color: var(--text3); margin-top: 9px; }

/* ------------------------------ hero ------------------------------ */
.pm-hero {
  position: relative; border-radius: 16px; padding: 20px 22px; margin-bottom: 16px;
  border: 1px solid rgba(91,140,255,.22); overflow: hidden;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(91,140,255,.14), transparent 55%),
    radial-gradient(110% 130% at 100% 100%, rgba(64,190,160,.1), transparent 50%),
    var(--card);
}
.pm-hero h2 { font-size: 16px; font-weight: 600; margin: 0 0 7px; letter-spacing: .2px; }
.pm-hero p { margin: 0; font-size: 12px; color: var(--text3); line-height: 1.8; max-width: 860px; }
.pm-hero p b { color: var(--tone-info); font-weight: 600; }

/* 状态条：引擎连接 / 操作反馈 */
.pm-status {
  display: inline-flex; align-items: center; gap: 8px; margin: 12px 0 0;
  font-size: 12px; color: var(--text2);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  background: var(--card2);
}
.pm-status.error { border-color: rgba(255,92,92,.45); color: var(--tone-danger); background: rgba(255,92,92,.1); }
.pm-status .ok, .pm-status.ok { color: var(--tone-ok); }
#engineDot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }
#engineDot.ok { background: #41d19a; box-shadow: 0 0 8px rgba(65,209,154,.6); }

/* ------------------------------ 双栏 ------------------------------ */
/* 断点按「列表 320 + 详情 380 + 间距」算：窄于这个宽度才竖排。
   1180 那档会把设置弹窗（右栏约 870）也压成竖排，一屏只看得到列表。 */
.pm-layout { display: flex; gap: 16px; align-items: flex-start; }
@media (max-width: 760px) { .pm-layout { flex-direction: column; } }

.pm-list { width: 320px; flex: none; display: flex; flex-direction: column; gap: 9px;
  max-height: 72vh; overflow: auto; padding-right: 4px; }
@media (max-width: 760px) {
  .pm-list { width: 100%; max-height: none; }
}

.pm-list .pm-card { animation: pm-in .16s ease-out both; }
@keyframes pm-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 弹窗表单与说明（plugin-manager.js 动态生成） */
.pm-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text3); }
.pm-field input {
  background: var(--card2); border: 1px solid var(--line2); border-radius: 9px;
  padding: 8px 10px; font-size: 12.5px; color: var(--text); outline: none; width: 100%;
  box-sizing: border-box; transition: border-color .15s, box-shadow .15s;
}
.pm-field input:focus { border-color: rgba(91,140,255,.55); box-shadow: 0 0 0 3px rgba(91,140,255,.1); }
.pm-subhead { font-size: 12px; font-weight: 600; color: var(--text); padding: 2px 0; }
.pm-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); cursor: pointer; }
.pm-check input { accent-color: #5b8cff; }
.pm-muted { font-size: 11.5px; color: var(--text3); line-height: 1.7; margin: 6px 0 0; }

/* 上传安装：拖拽 / 选文件 */
.pm-drop {
  border: 1.5px dashed rgba(91,140,255,.4); border-radius: 12px; padding: 18px 16px;
  text-align: center; font-size: 12px; color: var(--text2); cursor: pointer;
  background: radial-gradient(80% 120% at 50% 0%, rgba(91,140,255,.07), transparent 60%), var(--card);
  transition: border-color .15s, background .15s, transform .15s;
  margin-bottom: 12px;
}
.pm-drop:hover { border-color: rgba(91,140,255,.65); }
.pm-drop.over {
  border-color: rgba(91,140,255,.85); background: rgba(91,140,255,.1);
  transform: scale(1.015); box-shadow: 0 0 0 3px rgba(91,140,255,.14);
}
.pm-drop b { color: var(--text); font-size: 13px; display: block; margin-bottom: 5px; }
.pm-drop small { color: var(--text3); }
.pm-drop input[type="file"] { display: none; }

.pm-card {
  position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: var(--card2); cursor: pointer; overflow: hidden; width: 100%; text-align: left;
  color: var(--text); font: inherit; box-sizing: border-box;
  transition: border-color .16s, transform .16s, box-shadow .16s, background .16s;
}
.pm-card:hover { border-color: rgba(91,140,255,.4); transform: translateY(-1px); }
.pm-card.on {
  border-color: rgba(91,140,255,.6); background: var(--accent-soft);
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
}
.pm-card.on::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #5b8cff, #40bea0);
}

/* 卡片里两行：名字 + 版本 / 徽标组（plugin-manager.js 的 pm-card-top / pm-card-tags） */
.pm-card-top { display: flex; align-items: baseline; gap: 8px; }
.pm-card-top b {
  font-size: 13px; font-weight: 600; color: var(--text); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pm-card-top small { margin-left: auto; flex: none; font-size: 10.5px; color: var(--text3); }
.pm-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pm-card-tags em { font-style: normal; }
.pm-card-head { display: flex; align-items: center; gap: 10px; }
.pm-icon {
  width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-size: 15px; background: rgba(91,140,255,.14); border: 1px solid rgba(91,140,255,.3); color: var(--tone-accent);
}
.pm-card.on .pm-icon { background: rgba(91,140,255,.22); }
.pm-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-meta {
  display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pm-badge {
  display: inline-block; border-radius: 6px; padding: 2px 9px; font-size: 10.5px;
  border: 1px solid var(--line2); background: rgba(10,10,12,.5); color: var(--text2);
}
.pm-badge.v2 { background: rgba(64,190,160,.18); border-color: rgba(64,190,160,.5); color: #bdf0dd; }
/* 状态徽标：后端给的是 enabled / disabled / removed（app/channel_plugins.py:describe），
   以前只写了 on / off，三个真实状态全都没上色——列表里看不出哪个是启用的。 */
.pm-state {
  display: inline-block; font-style: normal; white-space: nowrap;
  font-size: 10.5px; border-radius: 6px; padding: 2px 9px;
  border: 1px solid var(--line2); background: var(--pill); color: var(--text3);
}
.pm-state.enabled, .pm-state.on {
  background: rgba(65,209,154,.16); border-color: rgba(65,209,154,.5); color: var(--tone-ok);
}
.pm-state.disabled, .pm-state.off {
  background: rgba(255,255,255,.06); border-color: var(--line2); color: var(--text3);
}
.pm-state.removed {
  background: rgba(255,92,92,.12); border-color: rgba(255,92,92,.45); color: var(--tone-danger);
}
/* 「默认执行端」/「内置」是身份不是状态，用不同的形：一个描边强调色，一个纯灰。 */
.pm-default {
  display: inline-block; font-style: normal; font-size: 10.5px; white-space: nowrap;
  border-radius: 6px; padding: 2px 9px;
  border: 1px solid rgba(91,140,255,.5); background: rgba(91,140,255,.14); color: var(--tone-info);
}
.pm-builtin {
  display: inline-block; font-style: normal; font-size: 10.5px; white-space: nowrap;
  border-radius: 6px; padding: 2px 9px;
  border: 1px solid var(--line2); background: transparent; color: var(--text3);
}
.pm-builtin.alt { border-style: dashed; }

.pm-empty { text-align: center; padding: 46px 18px; border: 1px dashed var(--line2); border-radius: 14px; color: var(--text3); font-size: 12.5px; line-height: 1.8; background: var(--card2); }

/* ------------------------------ 详情 ------------------------------ */
.pm-detail {
  border: 1px solid var(--line); border-radius: 14px; background: var(--card2);
  padding: 18px 20px; min-height: 240px; display: flex; flex-direction: column; gap: 14px;
  flex: 1; min-width: 0;
}
/* 详情头：名字 + 状态徽标；下面是键值表（<dl>，一行一条，键淡值亮） */
.pm-detail h3 {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 15px; font-weight: 600; color: var(--text); margin: 0;
}
.pm-detail dl.pm-meta {
  display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 8px 14px;
  margin: 0; font-size: 11.5px; white-space: normal; overflow: visible;
}
.pm-detail dl.pm-meta dt { color: var(--text3); }
.pm-detail dl.pm-meta dd {
  margin: 0; color: var(--text2); line-height: 1.6; min-width: 0; word-break: break-word;
}
.pm-desc { margin: 0; font-size: 12px; line-height: 1.8; color: var(--text2); }
.pm-default-link { align-self: flex-start; }
@media (max-width: 760px) {
  .pm-detail dl.pm-meta { grid-template-columns: 66px minmax(0, 1fr); }
}
.pm-detail-head { display: flex; align-items: flex-start; gap: 14px; }
.pm-detail-head .pm-icon { width: 44px; height: 44px; font-size: 20px; }
.pm-detail-head h3 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 5px; }
.pm-detail-head .pm-meta { flex-wrap: wrap; white-space: normal; }
/* 底部操作条（启用 / 停用 / 删除）——在详情的下一行，不是详情头里的右对齐按钮组 */
.pm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; }
.pm-actions button {
  border: 1px solid var(--line2); background: var(--card); color: var(--text2);
  border-radius: 8px; padding: 6px 13px; font-size: 12px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.pm-actions button:hover { background: var(--pill-hi); color: var(--text); }
.pm-actions button.primary { border-color: rgba(91,140,255,.5); background: rgba(91,140,255,.12); color: var(--tone-info); }
.pm-actions button.primary:hover { background: rgba(91,140,255,.24); }
.pm-actions button.danger { border-color: rgba(255,92,92,.4); color: var(--tone-danger); }
.pm-actions button.danger:hover { background: rgba(255,92,92,.12); }

.pm-file {
  font-size: 11.5px; color: var(--text3); font-family: ui-monospace, Consolas, monospace;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card);
  padding: 8px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pm-section { border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; background: var(--card); }
.pm-section > b { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.pm-section > b .pm-state { margin-left: 0; }
.pm-doc { font-size: 12px; color: var(--text2); line-height: 1.8; margin: 9px 0 0; white-space: pre-wrap; }
.pm-config { margin: 10px 0 0; display: flex; flex-direction: column; gap: 10px; }
.pm-key { display: flex; align-items: center; gap: 9px; }
.pm-key code {
  font-size: 11px; color: var(--tone-accent); background: rgba(91,140,255,.1);
  border-radius: 6px; padding: 4px 8px; white-space: nowrap;
}
.pm-key input, .pm-key select {
  flex: 1; min-width: 0; background: var(--card2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.pm-key input:focus, .pm-key select:focus {
  border-color: rgba(91,140,255,.55); box-shadow: 0 0 0 3px rgba(91,140,255,.1);
}
.pm-key small { font-size: 11px; color: var(--text3); flex: none; }

.pm-alert {
  border: 1px solid rgba(255,92,92,.4); background: rgba(255,92,92,.09); color: var(--tone-danger);
  border-radius: 10px; padding: 10px 14px; font-size: 12px; margin-bottom: 14px;
}
.pm-warn {
  border: 1px solid rgba(239,159,39,.4); background: rgba(239,159,39,.09); color: var(--tone-warn);
  border-radius: 10px; padding: 10px 14px; font-size: 12px; margin-bottom: 14px; line-height: 1.7;
}

/* ------------------------------ 弹窗 ------------------------------
   plugins.html 的结构是「#previewMask 遮罩 + #previewModal 对话框」，没有额外卡片层，
   所以 .pm-modal 本身就是那张卡：固定居中、限宽限高、内部滚动。 */
.pm-mask {
  position: fixed; inset: 0; z-index: 299;
  background: rgba(0, 0, 0, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.pm-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 300;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55); animation: pm-pop .18s ease-out;
}
@keyframes pm-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.pm-modal-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--card);
}
.pm-modal-head strong { font-size: 14px; font-weight: 600; }
.pm-x { font-size: 20px; line-height: 1; color: var(--text3); padding: 0 4px; }
.pm-x:hover { color: var(--text); }
.pm-modal-body {
  flex: 1; min-height: 0; overflow: auto;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 13px;
}
.pm-modal-foot {
  flex: none; display: flex; justify-content: flex-end; gap: 9px;
  padding: 12px 18px; border-top: 1px solid var(--line); background: var(--card);
}
.pm-modal-foot button {
  border: 1px solid var(--line2); border-radius: 8px; padding: 7px 14px;
  font-size: 12.5px; color: var(--text2); background: var(--card);
  transition: background .15s, color .15s, border-color .15s;
}
.pm-modal-foot button:hover { background: var(--pill-hi); color: var(--text); }
.pm-modal-foot button.primary { border-color: rgba(91,140,255,.5); background: rgba(91,140,255,.14); color: var(--tone-info); }

.pm-actions-foot { display: flex; gap: 8px; }
.pm-actions-foot button {
  flex: 1; border: 1px solid var(--line2); border-radius: 8px; padding: 7px 0;
  font-size: 12px; color: var(--text2); background: var(--card);
  transition: background .15s, color .15s, border-color .15s;
}
.pm-actions-foot button:hover { background: var(--pill-hi); color: var(--text); }
.pm-actions-foot button.primary { border-color: rgba(91,140,255,.5); background: rgba(91,140,255,.14); color: var(--tone-info); }

.pm-doc-files { display: flex; flex-direction: column; gap: 7px; }
.pm-doc-files > div {
  display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text2);
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; background: var(--card2);
  flex-wrap: wrap;
}
.pm-doc-files code { font-size: 11px; color: var(--tone-accent); }
.pm-doc-files button { margin-left: auto; font-size: 11px; color: var(--text3); }
.pm-doc-files button:hover { color: var(--text); }
.pm-doc-files .newfile { flex: 1; min-width: 120px; background: var(--card2); border: 1px solid var(--line2);
  border-radius: 8px; padding: 5px 9px; font-size: 11.5px; color: var(--text); outline: none; }

/* 页内提示：贴底居中，不挡内容；与设置弹窗的 .sm-toast 同一观感 */
.pm-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  max-width: min(520px, 88vw); padding: 9px 15px; border-radius: 10px; z-index: 320;
  background: var(--card); border: 1px solid var(--line2); color: var(--text);
  font-size: 12.5px; line-height: 1.6; box-shadow: 0 14px 38px rgba(0,0,0,.4);
}
.pm-toast.error { border-color: var(--danger); color: var(--tone-danger); }
