/* ComfyUI 手机 App 样式 */
:root {
  --bg:#0c0e14; --panel:#141821; --card:#1a1f2b; --node:#232936; --nodehd:#313a4d; --line:#2a3140;
  --text:#dde2ec; --dim:#8b95aa; --accent:#3688ff; --accent2:#9d7cff;
  --ok:#3ddc97; --warn:#ffd166; --err:#ff6b6b;
  --c-string:#ffd166; --c-model:#9d7cff; --c-size:#4dd0e1; --c-image:#3688ff; --c-video:#3ddc97;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; overflow: hidden;
  padding-top: var(--sat);
}
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.appbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.appbar .logo { width: 34px; height: 34px; border-radius: 8px; }
.appbar .ttl-wrap { flex: 1; min-width: 0; }
.appbar .ttl { font-weight: 700; font-size: 16px; line-height: 1.2; }
.appbar .sub { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .install {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none;
  border-radius: 999px; padding: 7px 14px; font-size: 12px; font-weight: 600;
}

/* ---------- 页面 ---------- */
.page { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(12px + var(--sab)); display: flex; flex-direction: column; gap: 12px; }
.page[hidden] { display: none; }
.page-flow { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---------- 卡片表单 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.lab { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 5px; }
.card > .lab:first-child { margin-top: 0; }
textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px; font-size: 14px; resize: vertical; outline: none; font-family: inherit;
}
textarea:focus, select:focus { border-color: var(--accent); }
select {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 8px; font-size: 13px; outline: none;
}
.row2 { display: flex; gap: 10px; }
.row2 > div { flex: 1; min-width: 0; }
.up {
  width: 100%; background: var(--card); border: 1px dashed var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 8px; font-size: 13px; cursor: pointer;
}
.refprev { width: 100%; max-height: 150px; object-fit: contain; border-radius: 10px; margin-top: 8px; background: #101218; }
.go {
  width: 100%; margin-top: 14px; background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.go:disabled { opacity: .5; }
.st { margin-top: 8px; font-size: 12px; color: var(--dim); line-height: 1.5; word-break: break-all; min-height: 16px; }
.st.err { color: var(--err); }
.st.ok { color: var(--ok); }

/* ---------- 结果 ---------- */
.result { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.result video, .result img { width: 100%; border-radius: 12px; display: block; background: #000; }
.result .rwrap { position: relative; }
.result .dl {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff;
  border: none; border-radius: 8px; padding: 5px 10px; font-size: 11px; text-decoration: none;
}

/* ---------- 工作流 ---------- */
.fbar {
  flex: 0 0 auto; display: flex; gap: 6px; align-items: center; padding: 8px;
  background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto;
}
.fbar select { width: auto; padding: 7px 6px; font-size: 12px; border-radius: 8px; flex: 0 0 auto; }
.fbtn {
  flex: 0 0 auto; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 7px 11px; font-size: 12px; cursor: pointer;
}
.fbtn.run { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none; font-weight: 700; }
.fbtn:disabled { opacity: .5; }

#flow {
  position: relative; flex: 1 1 auto; overflow: hidden; touch-action: none;
  background-color: #101218;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 22px 22px;
}
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#wires path.hit { stroke: transparent; stroke-width: 16; fill: none; pointer-events: stroke; cursor: pointer; }
#wires path.wire { fill: none; stroke-width: 2.5; pointer-events: none; }
#wires path.tmp { fill: none; stroke: #8a93a8; stroke-width: 2.5; stroke-dasharray: 6 4; }
.fhint {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  background: rgba(0,0,0,.55); color: var(--dim); font-size: 10px; padding: 4px 10px;
  border-radius: 999px; white-space: nowrap; pointer-events: none;
}

.node {
  position: absolute; width: 210px; background: var(--node); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.35); font-size: 12px; user-select: none;
}
.node.sel { border-color: var(--accent); }
.node.running { border-color: var(--warn); box-shadow: 0 0 0 1px rgba(255,209,102,.35), 0 6px 18px rgba(0,0,0,.35); }
.node.done { border-color: var(--ok); }
.node.err { border-color: var(--err); }
.node .hd { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--nodehd);
  border-radius: 9px 9px 0 0; font-weight: 600; font-size: 12px; touch-action: none; }
.node .hd .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .hd .x { cursor: pointer; color: var(--dim); font-size: 15px; line-height: 1; padding: 2px 6px; }
.node .hd .x:hover { color: var(--err); }
.node .bd { padding: 8px 10px 10px; }
.node .fld { margin-bottom: 6px; color: var(--dim); font-size: 11px; }
.node .io { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 0; }
.node .io .lab { color: var(--text); font-size: 11px; margin: 0; }
.node .io.in { justify-content: flex-start; }
.node .io.out { justify-content: flex-end; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #14161c; flex: 0 0 auto; position: relative; touch-action: none; }
.dot::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; }  /* 扩大触控热区 */
.dot.in { margin-left: -16px; }
.dot.out { margin-right: -16px; }
.node textarea { font-size: 12px; padding: 6px 8px; border-radius: 8px; }
.node select { font-size: 12px; padding: 6px 6px; border-radius: 8px; }
.node .stat { margin-top: 6px; font-size: 11px; color: var(--dim); min-height: 14px; word-break: break-all; }
.node .stat.ok { color: var(--ok); }
.node .stat.err { color: var(--err); }
.node .mini { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.node .mini img, .node .mini video { max-width: 100%; border-radius: 6px; display: block; }
.node .mini img { width: 100%; }
.node .upbtn { font-size: 11px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; width: 100%; }
.node .prev { margin-top: 6px; max-width: 100%; border-radius: 6px; display: block; }
.node .dla { display: inline-block; margin-top: 5px; font-size: 11px; color: var(--accent); }

.flog {
  flex: 0 0 auto; height: 74px; overflow-y: auto; background: #0c0e13; border-top: 1px solid var(--line);
  padding: 6px 12px; font-size: 11px; line-height: 1.6; color: var(--dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.flog .l-ok { color: var(--ok); } .flog .l-err { color: var(--err); } .flog .l-warn { color: var(--warn); }

/* ---------- 底部 Tab ---------- */
.tabbar {
  flex: 0 0 auto; display: flex; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: var(--sab);
}
.tab {
  flex: 1; background: none; border: none; color: var(--dim); padding: 8px 0 9px;
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tab .ic { font-size: 19px; line-height: 1; filter: grayscale(1) opacity(.6); }
.tab.on { color: var(--accent); font-weight: 600; }
.tab.on .ic { filter: none; }

/* ---------- 全屏查看 ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 99; background: rgba(8,9,12,.94);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.viewer[hidden] { display: none; }
.vbody { max-width: 100%; max-height: 100%; }
.vbody img, .vbody video { max-width: 100%; max-height: 82vh; border-radius: 10px; display: block; }
.vbody .vdl {
  display: block; text-align: center; margin-top: 12px; color: #fff; text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 999px; padding: 10px 22px; font-size: 13px; font-weight: 600;
}
.vclose {
  position: absolute; top: calc(10px + var(--sat)); right: 12px; width: 38px; height: 38px;
  border-radius: 50%; border: 1px solid var(--line); background: rgba(0,0,0,.5); color: #fff;
  font-size: 20px; cursor: pointer;
}

/* ---------- 顶栏「我的」 ---------- */
.appbar .lib {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 600;
}

/* ---------- chips / 曲风 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--dim);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.chip.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.mus-go { margin-top: 12px; }
.dl-link { display: block; text-align: center; text-decoration: none; color: var(--text); line-height: 1.3; padding: 10px 8px; border-style: solid; }
.lib-head { display: flex; align-items: center; justify-content: space-between; }
.lib-head .lab { margin: 0; }
.mini {
  background: var(--card); border: 1px solid var(--line); color: var(--dim);
  border-radius: 8px; padding: 5px 10px; font-size: 11px; cursor: pointer;
}

/* ---------- 歌曲列表 ---------- */
.mlist { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.mrow {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.mrow .mico { color: var(--accent2); font-size: 15px; }
.mrow .mtitle { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .mplay { font-size: 11px; color: var(--dim); }

/* ---------- 媒体库 ---------- */
.lib-bar { display: flex; align-items: center; gap: 8px; }
.lib-bar .chips { flex: 1; flex-wrap: nowrap; overflow-x: auto; }
.lib-bar .up { width: auto; flex: 0 0 auto; padding: 8px 14px; }
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mcard {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; cursor: pointer;
}
.mthumb { position: relative; width: 100%; aspect-ratio: 1 / 1; background: #101318; display: flex; align-items: center; justify-content: center; }
.mthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mthumb .ph { font-size: 26px; color: var(--dim); }
.mthumb .ph.music { color: var(--accent2); }
.mthumb .badge {
  position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff;
  border-radius: 6px; font-size: 10px; padding: 2px 5px;
}
.mname { font-size: 11px; color: var(--text); padding: 6px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdel {
  position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; line-height: 1;
  background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; font-size: 14px; padding: 0;
}
.empty { color: var(--dim); font-size: 13px; text-align: center; padding: 26px 12px; }
.empty.sm { padding: 12px; font-size: 12px; }

/* ---------- 剪辑 ---------- */
.page-edit { padding: 8px 8px calc(8px + var(--sab)); gap: 8px; }
.ed-stage { background: #000; border-radius: 12px; overflow: hidden; display: flex; justify-content: center; }
.ed-stage canvas { max-width: 100%; max-height: 42vh; display: block; background: #000; }
.ed-time { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.ed-meta { font-size: 11px; color: var(--dim); margin-bottom: 6px; }
.ed-tracks { position: relative; display: flex; flex-direction: column; gap: 6px; }
.ed-row { display: flex; align-items: center; gap: 6px; }
.ed-row > i { flex: 0 0 30px; font-style: normal; font-size: 10px; color: var(--dim); }
.ed-track {
  position: relative; flex: 1; min-height: 34px; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 2px; overflow: hidden;
}
.ed-track.sub { min-height: 22px; }
.ed-clip {
  position: relative; flex: 0 0 auto; background: linear-gradient(135deg, rgba(54,136,255,.35), rgba(157,124,255,.35));
  border: 1px solid rgba(54,136,255,.6); border-radius: 6px; padding: 3px 8px; overflow: hidden; cursor: pointer;
}
.ed-clip.on { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2) inset; }
.ed-clip-t { font-size: 10px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-clip-s { font-size: 9px; color: rgba(255,255,255,.7); }
.ed-handle { position: absolute; top: 0; bottom: 0; width: 16px; cursor: ew-resize; }
.ed-handle.l { left: 0; } .ed-handle.r { right: 0; }
.ed-handle::after {
  content: ''; position: absolute; top: 6px; bottom: 6px; width: 2px; background: rgba(255,255,255,.7); border-radius: 2px;
}
.ed-handle.l::after { left: 4px; } .ed-handle.r::after { right: 4px; }
.ed-bgm { width: 100%; font-size: 10px; color: var(--accent2); padding: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-sub {
  position: absolute; top: 2px; height: 18px; background: rgba(255,209,102,.25);
  border: 1px solid rgba(255,209,102,.5); border-radius: 4px; font-size: 9px; color: #ffd166;
  overflow: hidden; white-space: nowrap; padding: 0 4px; cursor: pointer;
}
.ed-head { position: absolute; left: 0; top: -4px; bottom: -4px; width: 2px; background: var(--err); pointer-events: none; }
.ed-empty { font-size: 10px; color: var(--dim); padding: 10px; }
.ed-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.ed-p-t { font-size: 13px; font-weight: 600; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-p-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ed-p-row > span { flex: 0 0 34px; font-size: 11px; color: var(--dim); }
.ed-p-row > input[type=range] { flex: 1; accent-color: var(--accent); }
.ed-p-row > b { flex: 0 0 46px; font-size: 11px; text-align: right; font-weight: 500; }
.ed-p-row select { flex: 1; padding: 6px; font-size: 12px; }
.ed-p-btns { display: flex; gap: 6px; margin-top: 10px; }
.ed-p-btns button {
  flex: 1; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 4px; font-size: 11px; cursor: pointer;
}
.ed-p-btns button.danger { color: var(--err); border-color: rgba(255,107,107,.5); }
.ed-bar { display: flex; flex-direction: column; gap: 8px; }
.ed-bar > #edPlay {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none;
  border-radius: 10px; padding: 10px; font-size: 14px; font-weight: 700;
}
.ed-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-tools button {
  flex: 1 1 22%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 4px; font-size: 12px; cursor: pointer;
}
.ed-tools button.run { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none; font-weight: 700; }
.ed-save { margin-top: 2px; background: var(--ok); color: #06231a; border: none; font-weight: 700; }
.ed-prog { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.ed-prog-bar { height: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0%; border-radius: 4px; transition: width .4s; }
.ed-prog span { display: block; font-size: 11px; color: var(--dim); margin-top: 5px; }
.ed-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; border-radius: 10px; padding: 9px 16px; font-size: 12px; z-index: 60;
}

/* ---------- 素材选择弹层 ---------- */
.picker { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 70; display: flex; align-items: flex-end; }
.picker[hidden] { display: none; }
.pk-box { width: 100%; background: var(--panel); border-radius: 16px 16px 0 0; padding: 12px; max-height: 70vh; display: flex; flex-direction: column; }
.pk-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.pk-head button { background: none; border: none; color: var(--dim); font-size: 20px; }
.pk-body { overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pk-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; }
.pk-th { width: 100%; aspect-ratio: 1 / 1; background: #101318; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 22px; }
.pk-th img { width: 100%; height: 100%; object-fit: cover; }
.pk-t { font-size: 11px; padding: 5px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-empty { grid-column: 1 / -1; color: var(--dim); font-size: 12px; text-align: center; padding: 20px; }

/* ---------- 全屏播放器 ---------- */
.vplayer { width: 100%; text-align: center; }
.vtitle { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.vplayer audio { width: 100%; margin-bottom: 10px; }
.vlyric { font-size: 12px; color: var(--dim); line-height: 1.8; max-height: 40vh; overflow-y: auto; white-space: pre-wrap; }
.vbar { display: flex; gap: 8px; justify-content: center; margin-top: 10px; align-items: center; }
.vuse, .vdl {
  display: inline-block; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  border: none; border-radius: 8px; padding: 8px 14px; font-size: 12px; text-decoration: none; cursor: pointer;
}
.vdl { background: rgba(255,255,255,.14); }
